Author: ema
Date: Mon Jan 17 04:11:17 2011
New Revision: 1059746
URL: http://svn.apache.org/viewvc?rev=1059746&view=rev
Log:
[CXF-3250]:Fix issue EPR's address is NOT used for invocations on the endpoint
when the dispatchImpl is created with EPR
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Modified:
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=1059746&r1=1059745&r2=1059746&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++
cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Mon Jan 17 04:11:17 2011
@@ -252,11 +252,17 @@ public class ServiceImpl extends Service
}
}
}
-
+
if (ei == null) {
Message msg = new Message("INVALID_PORT", BUNDLE, portName);
throw new WebServiceException(msg.toString());
}
+
+ //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());
+ }
try {
return new JaxWsClientEndpointImpl(bus, service, ei, this,
@@ -628,7 +634,13 @@ public class ServiceImpl extends Service
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);
return disp;
@@ -640,11 +652,12 @@ public class ServiceImpl extends Service
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);
}
-
@Override
public Dispatch<Object> createDispatch(QName portName, JAXBContext
context, Mode mode) {
return createDispatch(portName, context, mode, new
WebServiceFeature[]{});
@@ -691,8 +704,9 @@ public class ServiceImpl extends Service
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
@@ -708,7 +722,14 @@ public class ServiceImpl extends Service
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:
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=1059746&r1=1059745&r2=1059746&view=diff
==============================================================================
---
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
(original)
+++
cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Mon Jan 17 04:11:17 2011
@@ -42,6 +42,8 @@ import javax.xml.ws.Response;
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;
@@ -70,6 +72,7 @@ import org.apache.hello_world_soap_http.
import org.junit.BeforeClass;
import org.junit.Test;
+
public class DispatchClientServerTest extends AbstractBusClientServerTestBase {
private static final QName SERVICE_NAME
@@ -268,6 +271,35 @@ public class DispatchClientServerTest ex
}
@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());
+ }
+
+ @Test
public void testDOMSourceMESSAGE() throws Exception {
/*URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(wsdl);