cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r545438 - in /incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch: client/Client.java server/GreeterSoapMessageProvider.java
Date Fri, 08 Jun 2007 06:38:24 GMT
Author: jliu
Date: Thu Jun  7 23:38:24 2007
New Revision: 545438

URL: http://svn.apache.org/viewvc?view=rev&rev=545438
Log:
CXF-713: dispatch_provider sample in the latest build does not work anymore

Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/client/Client.java
    incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/server/GreeterSoapMessageProvider.java

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/client/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/client/Client.java?view=diff&rev=545438&r1=545437&r2=545438
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/client/Client.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/client/Client.java
Thu Jun  7 23:38:24 2007
@@ -30,22 +30,26 @@
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Service.Mode;
 
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
 import org.apache.hello_world_soap_http.SOAPService1;
 import org.apache.hello_world_soap_http.SOAPService2;
 import org.apache.hello_world_soap_http.SOAPService3;
 
 public final class Client {
-    
+
     private Client() {
-    } 
+    }
 
     public static void main(String args[]) throws Exception {
-        
-        if (args.length == 0) { 
+
+        if (args.length == 0) {
             System.out.println("please specify wsdl");
-            System.exit(1); 
+            System.exit(1);
         }
-    
+
         URL wsdlURL;
         File wsdlFile = new File(args[0]);
         if (wsdlFile.exists()) {
@@ -53,14 +57,14 @@
         } else {
             wsdlURL = new URL(args[0]);
         }
-        
+
         MessageFactory factory = MessageFactory.newInstance();
         System.out.println(wsdlURL + "\n\n");
 
         QName serviceName1 = new QName("http://apache.org/hello_world_soap_http", "SOAPService1");
-        QName portName1 = new QName("http://apache.org/hello_world_soap_http", "SoapPort1");

-        
-        SOAPService1 service1 = new SOAPService1(wsdlURL, serviceName1);        
+        QName portName1 = new QName("http://apache.org/hello_world_soap_http", "SoapPort1");
+
+        SOAPService1 service1 = new SOAPService1(wsdlURL, serviceName1);
         InputStream is1 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq1.xml");
         if (is1 == null) {
             System.err.println("Failed to create input stream from file "
@@ -69,16 +73,16 @@
         }
         SOAPMessage soapReq1 = factory.createMessage(null, is1);
 
-        Dispatch<SOAPMessage> dispSOAPMsg = service1.createDispatch(portName1, 
+        Dispatch<SOAPMessage> dispSOAPMsg = service1.createDispatch(portName1,
                                                                     SOAPMessage.class, Mode.MESSAGE);
-        
+
         System.out.println("Invoking server through Dispatch interface using SOAPMessage");
-        SOAPMessage soapResp = dispSOAPMsg.invoke(soapReq1);        
-        System.out.println("Response from server: " + soapResp.getSOAPBody().getTextContent());
       
+        SOAPMessage soapResp = dispSOAPMsg.invoke(soapReq1);
+        System.out.println("Response from server: " + soapResp.getSOAPBody().getTextContent());
 
         QName serviceName2 = new QName("http://apache.org/hello_world_soap_http", "SOAPService2");
-        QName portName2 = new QName("http://apache.org/hello_world_soap_http", "SoapPort2");

-        
+        QName portName2 = new QName("http://apache.org/hello_world_soap_http", "SoapPort2");
+
         SOAPService2 service2 = new SOAPService2(wsdlURL, serviceName2);
         InputStream is2 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq2.xml");
         if (is2 == null) {
@@ -89,18 +93,18 @@
         SOAPMessage soapReq2 = factory.createMessage(null, is2);
         DOMSource domReqMessage = new DOMSource(soapReq2.getSOAPPart());
 
-        Dispatch<DOMSource> dispDOMSrcMessage = service2.createDispatch(portName2,

+        Dispatch<DOMSource> dispDOMSrcMessage = service2.createDispatch(portName2,
                                                                         DOMSource.class,
Mode.MESSAGE);
         System.out.println("Invoking server through Dispatch interface using DOMSource in
MESSAGE Mode");
-        DOMSource domRespMessage = dispDOMSrcMessage.invoke(domReqMessage);        
-        System.out.println("Response from server: " 
-                           + domRespMessage.getNode().getLastChild().getTextContent()); 
-              
+        DOMSource domRespMessage = dispDOMSrcMessage.invoke(domReqMessage);
+        System.out.println("Response from server: "
+                           + domRespMessage.getNode().getLastChild().getTextContent());
+
 
         QName serviceName3 = new QName("http://apache.org/hello_world_soap_http", "SOAPService3");
-        QName portName3 = new QName("http://apache.org/hello_world_soap_http", "SoapPort3");

-        
-        SOAPService3 service3 = new SOAPService3(wsdlURL, serviceName3);        
+        QName portName3 = new QName("http://apache.org/hello_world_soap_http", "SoapPort3");
+
+        SOAPService3 service3 = new SOAPService3(wsdlURL, serviceName3);
         InputStream is3 =  Client.class.getResourceAsStream("GreetMeDocLiteralReq3.xml");
         if (is3 == null) {
             System.err.println("Failed to create input stream from file "
@@ -110,15 +114,28 @@
 
         SOAPMessage soapReq3 = MessageFactory.newInstance().createMessage(null, is3);
         DOMSource domReqPayload = new DOMSource(soapReq3.getSOAPBody().extractContentAsDocument());
-             
-        Dispatch<DOMSource> dispDOMSrcPayload = service3.createDispatch(portName3,

+
+        Dispatch<DOMSource> dispDOMSrcPayload = service3.createDispatch(portName3,
                                                                         DOMSource.class,
Mode.PAYLOAD);
         System.out.println("Invoking server through Dispatch interface using DOMSource in
PAYLOAD Mode");
-        DOMSource domRespPayload = dispDOMSrcPayload.invoke(domReqPayload);        
-        System.out.println("Response from server: " 
-                           + domRespPayload.getNode().getFirstChild().getTextContent());

-        
-        System.exit(0); 
+        DOMSource domRespPayload = dispDOMSrcPayload.invoke(domReqPayload);
+
+        System.out.println("Response from server: "
+                           + fetchElementByName(domRespPayload.getNode(), "responseType").getTextContent());
+
+        System.exit(0);
     }
 
+    private static Element fetchElementByName(Node parent, String name) {
+        Element ret = null;
+        NodeList nodeList = parent.getChildNodes();
+        for (int i = 0; i < nodeList.getLength(); i++) {
+            Node node = nodeList.item(i);
+            if (node instanceof Element && ((Element)node).getLocalName().equals(name))
{
+                ret = (Element)node;
+                break;
+            }
+        }
+        return ret;
+    }
 }

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/server/GreeterSoapMessageProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/server/GreeterSoapMessageProvider.java?view=diff&rev=545438&r1=545437&r2=545438
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/server/GreeterSoapMessageProvider.java
(original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/dispatch_provider/src/demo/hwDispatch/server/GreeterSoapMessageProvider.java
Thu Jun  7 23:38:24 2007
@@ -30,17 +30,18 @@
 @WebServiceProvider(portName = "SoapPort1", serviceName = "SOAPService1",
                       targetNamespace = "http://apache.org/hello_world_soap_http",
                       wsdlLocation = "wsdl/hello_world.wsdl")
-@ServiceMode(value = Service.Mode.MESSAGE)            
+@ServiceMode(value = Service.Mode.MESSAGE)
 public class GreeterSoapMessageProvider implements Provider<SOAPMessage> {
 
     public GreeterSoapMessageProvider() {
         //Complete
     }
-    
+
     public SOAPMessage invoke(SOAPMessage request) {
-        SOAPMessage response = null;        
+        SOAPMessage response = null;
         try {
-            MessageFactory factory = MessageFactory.newInstance();            
+            System.out.println("Incoming Client Request as a SOAPMessage");
+            MessageFactory factory = MessageFactory.newInstance();
             InputStream is = getClass().getResourceAsStream("GreetMeDocLiteralResp1.xml");
             response =  factory.createMessage(null, is);
             is.close();



Mime
View raw message