[jbossws-commits] JBossWS SVN: r14877 - in thirdparty/cxf/branches/cxf-2.2.12: systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Tue Aug 16 07:23:54 EDT 2011


Author: jim.ma
Date: 2011-08-16 07:23:53 -0400 (Tue, 16 Aug 2011)
New Revision: 14877

Modified:
   thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
   thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Log:
[JBPAPP-5779]:JBossWS-EPR's address is NOT used for invocations on the endpoint when the dispatchImpl is created with EPR

Modified: thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java	2011-08-16 11:18:49 UTC (rev 14876)
+++ thirdparty/cxf/branches/cxf-2.2.12/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java	2011-08-16 11:23:53 UTC (rev 14877)
@@ -253,6 +253,12 @@
             }
         }
 
+        // When the dispatch is created from EPR, the EPR's address will be set in portInfo
+        PortInfoImpl portInfo = getPortInfo(portName);
+        if (portInfo != null && !portInfo.getAddress().equals(ei.getAddress())) {
+            ei.setAddress(portInfo.getAddress());
+        }   
+
         if (ei == null) {
             Message msg = new Message("INVALID_PORT", BUNDLE, portName);
             throw new WebServiceException(msg.toString());
@@ -621,6 +627,11 @@
         if (executor != null) {
             client.getEndpoint().setExecutor(executor);
         }
+        // Set the the EPR's address in EndpointInfo
+        PortInfoImpl portInfo = portInfos.get(portName);
+        if (portInfo != null && !StringUtils.isEmpty(portInfo.getAddress())) {
+            client.getEndpoint().getEndpointInfo().setAddress(portInfo.getAddress());
+        }
                 
         Dispatch<T> disp = new DispatchImpl<T>(client, mode, type);
         configureObject(disp);
@@ -633,7 +644,9 @@
                                           Mode mode,
                                           WebServiceFeature... features) {
         EndpointReferenceType ref = VersionTransformer.convertToInternal(endpointReference);
-        return createDispatch(EndpointReferenceUtils.getPortQName(ref, bus), 
+        QName portName = EndpointReferenceUtils.getPortQName(ref, bus);
+        updatePortInfoAddress(portName, EndpointReferenceUtils.getAddress(ref));
+        return createDispatch(portName, 
                               type, mode, features);
     }   
 
@@ -684,8 +697,9 @@
                                            Mode mode,
                                            WebServiceFeature... features) {
         EndpointReferenceType ref = VersionTransformer.convertToInternal(endpointReference);
-        return createDispatch(EndpointReferenceUtils.getPortQName(ref, bus), 
-                              context, mode, features);        
+        QName portName = EndpointReferenceUtils.getPortQName(ref, bus);
+        updatePortInfoAddress(portName, EndpointReferenceUtils.getAddress(ref));
+        return createDispatch(portName, context, mode, features);        
     }
 
     @Override
@@ -701,7 +715,14 @@
         client.getOutInterceptors().addAll(clientFact.getOutInterceptors());
         client.getInFaultInterceptors().addAll(clientFact.getInFaultInterceptors());
         client.getOutFaultInterceptors().addAll(clientFact.getOutFaultInterceptors());
-    }    
+    }
+
+    private void updatePortInfoAddress(QName portName, String eprAddress) {
+        PortInfoImpl portInfo = portInfos.get(portName);
+        if (!StringUtils.isEmpty(eprAddress) && portInfo != null) {
+            portInfo.setAddress(eprAddress);
+        }
+    }
 }
 
 

Modified: thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java	2011-08-16 11:18:49 UTC (rev 14876)
+++ thirdparty/cxf/branches/cxf-2.2.12/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java	2011-08-16 11:23:53 UTC (rev 14877)
@@ -42,6 +42,8 @@
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.soap.SOAPFaultException;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
@@ -774,6 +776,32 @@
         assertTrue("Expected: " + expected, XMLUtils.toString(streamSourceResp3).contains(expected3));
     }
 
+    @Test
+    public void testCreateDispatchWithEPR() throws Exception {
+
+        URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+        assertNotNull(wsdl);
+
+        SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
+        assertNotNull(service);
+
+        W3CEndpointReferenceBuilder builder = new W3CEndpointReferenceBuilder();
+        builder.address("http://localhost:" + greeterPort + "/SOAPDispatchService/SoapDispatchPort");
+        builder.serviceName(SERVICE_NAME);
+        builder.endpointName(PORT_NAME);
+        W3CEndpointReference w3cEpr = builder.build();
+        Dispatch<SOAPMessage> disp = service.createDispatch(w3cEpr, SOAPMessage.class, Service.Mode.MESSAGE);
+        InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
+        SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, is);
+        assertNotNull(soapReqMsg);
+        SOAPMessage soapResMsg = disp.invoke(soapReqMsg);
+
+        assertNotNull(soapResMsg);
+        String expected = "Hello TestSOAPInputMessage";
+        assertEquals("Response should be : Hello TestSOAPInputMessage", expected, soapResMsg.getSOAPBody()
+            .getTextContent().trim());
+    }
+
     class TestSOAPMessageHandler implements AsyncHandler<SOAPMessage> {
 
         String replyBuffer;



More information about the jbossws-commits mailing list