You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by em...@apache.org on 2011/01/17 06:32:33 UTC
svn commit: r1059752 - in /cxf/branches/2.3.x-fixes: ./
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Author: ema
Date: Mon Jan 17 05:32:33 2011
New Revision: 1059752
URL: http://svn.apache.org/viewvc?rev=1059752&view=rev
Log:
Merged revisions 1059746 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1059746 | ema | 2011-01-17 12:11:17 +0800 (Mon, 17 Jan 2011) | 1 line
[CXF-3250]:Fix issue EPR's address is NOT used for invocations on the endpoint when the dispatchImpl is created with EPR
........
Modified:
cxf/branches/2.3.x-fixes/ (props changed)
cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
svn:mergeinfo = /cxf/trunk:1059746
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=1059752&r1=1059751&r2=1059752&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Mon Jan 17 05:32:33 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/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=1059752&r1=1059751&r2=1059752&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java (original)
+++ cxf/branches/2.3.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java Mon Jan 17 05:32:33 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);