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 2013/05/29 10:07:50 UTC
svn commit: r1487391 - in /cxf/branches/2.7.x-fixes: ./
rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/
systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/
systests/ws-specs/src/test/resources/wsdl_systest_soap12/
Author: ema
Date: Wed May 29 08:07:50 2013
New Revision: 1487391
URL: http://svn.apache.org/r1487391
Log:
Merged revisions 1487389 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1487389 | ema | 2013-05-29 16:02:29 +0800 (Wed, 29 May 2013) | 1 line
[CXF-5405]:UndeclaredThrowableException thrown in the client side when server responses with wsa:OnlyNonAnonymousAddressSupported soap12 version fault message
........
Added:
cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_soap12/
- copied from r1487389, cxf/trunk/systests/ws-specs/src/test/resources/wsdl_systest_soap12/
Modified:
cxf/branches/2.7.x-fixes/ (props changed)
cxf/branches/2.7.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java
cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1487389
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.7.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java?rev=1487391&r1=1487390&r2=1487391&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java (original)
+++ cxf/branches/2.7.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java Wed May 29 08:07:50 2013
@@ -35,6 +35,8 @@ import javax.xml.namespace.QName;
import javax.xml.ws.WebFault;
import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.Soap12;
+import org.apache.cxf.binding.soap.SoapBinding;
import org.apache.cxf.binding.soap.SoapBindingConstants;
import org.apache.cxf.binding.soap.SoapFault;
import org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor;
@@ -378,14 +380,30 @@ public class MAPAggregatorImpl extends M
if (hasAnonymous && hasNonAnon && !hasAnon) {
message.put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
+ if (isSOAP12(message)) {
+ SoapFault soap12Fault = new SoapFault(
+ "Found anonymous address but non-anonymous required",
+ Soap12.getInstance().getSender());
+ soap12Fault.addSubCode(new QName(Names.WSA_NAMESPACE_NAME,
+ "OnlyNonAnonymousAddressSupported"));
+ throw soap12Fault;
+ }
+
throw new SoapFault("Found anonymous address but non-anonymous required",
- new QName(Names.WSA_NAMESPACE_NAME,
- "OnlyNonAnonymousAddressSupported"));
+ new QName(Names.WSA_NAMESPACE_NAME, "OnlyNonAnonymousAddressSupported"));
} else if (!onlyAnonymous && !hasNonAnon && hasAnon) {
message.put(FaultMode.class, FaultMode.UNCHECKED_APPLICATION_FAULT);
+ if (isSOAP12(message)) {
+ SoapFault soap12Fault = new SoapFault(
+ "Found non-anonymous address but only anonymous supported",
+ Soap12.getInstance().getSender());
+ soap12Fault.addSubCode(new QName(Names.WSA_NAMESPACE_NAME,
+ "OnlyAnonymousAddressSupported"));
+ throw soap12Fault;
+ }
+
throw new SoapFault("Found non-anonymous address but only anonymous supported",
- new QName(Names.WSA_NAMESPACE_NAME,
- "OnlyAnonymousAddressSupported"));
+ new QName(Names.WSA_NAMESPACE_NAME, "OnlyAnonymousAddressSupported"));
}
}
@@ -487,6 +505,13 @@ public class MAPAggregatorImpl extends M
// must be aggregated
//isFault = true;
//aggregate(message, isFault);
+ if (isSOAP12(message)) {
+ SoapFault soap12Fault = new SoapFault(ContextUtils.retrieveMAPFaultReason(message),
+ Soap12.getInstance().getSender());
+ soap12Fault.setSubCode(new QName(Names.WSA_NAMESPACE_NAME, ContextUtils
+ .retrieveMAPFaultName(message)));
+ throw soap12Fault;
+ }
throw new SoapFault(ContextUtils.retrieveMAPFaultReason(message),
new QName(Names.WSA_NAMESPACE_NAME,
ContextUtils.retrieveMAPFaultName(message)));
@@ -1205,5 +1230,15 @@ public class MAPAggregatorImpl extends M
Names.WSA_NONE_ADDRESS));
}
}
+
+ private boolean isSOAP12(Message message) {
+ if (message.getExchange().getBinding() instanceof SoapBinding) {
+ SoapBinding binding = (SoapBinding)message.getExchange().getBinding();
+ if (binding.getSoapVersion() == Soap12.getInstance()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Modified: cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java?rev=1487391&r1=1487390&r2=1487391&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java Wed May 29 08:07:50 2013
@@ -19,15 +19,18 @@
package org.apache.cxf.systest.ws.addr_feature;
+import javax.xml.namespace.QName;
import javax.xml.ws.Endpoint;
import org.apache.cxf.BusFactory;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.testutil.common.TestUtil;
import org.apache.cxf.ws.addressing.WSAddressingFeature;
public class Server extends AbstractBusTestServerBase {
- static final String PORT = allocatePort(Server.class);
+ public static final String PORT = TestUtil.getPortNumber(Server.class, 1);
+ public static final String PORT2 = TestUtil.getPortNumber(Server.class, 2);
EndpointImpl ep;
protected void run() {
setBus(BusFactory.getDefaultBus());
@@ -38,6 +41,20 @@ public class Server extends AbstractBusT
ep = (EndpointImpl) Endpoint.create(implementor);
ep.getFeatures().add(new WSAddressingFeature());
ep.publish(address);
+
+
+ ep = new EndpointImpl(BusFactory.getThreadDefaultBus(),
+ implementor,
+ null,
+ getWsdl());
+ ep.setServiceName(new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersService"));
+ ep.setEndpointName(new QName("http://apache.org/cxf/systest/ws/addr_feature/",
+ "AddNumbersNonAnonPort"));
+ String address12 = "http://localhost:" + PORT2 + "/jaxws/soap12/add";
+ ep.getFeatures().add(new WSAddressingFeature());
+ ep.publish(address12);
+
+
}
public void tearDown() {
@@ -56,4 +73,13 @@ public class Server extends AbstractBusT
System.out.println("done!");
}
}
+ private String getWsdl() {
+ try {
+ java.net.URL wsdl = getClass().getResource("/wsdl_systest_soap12/add_numbers_soap12.wsdl");
+ return wsdl.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
Modified: cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java?rev=1487391&r1=1487390&r2=1487391&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java (original)
+++ cxf/branches/2.7.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java Wed May 29 08:07:50 2013
@@ -41,7 +41,8 @@ import org.junit.BeforeClass;
import org.junit.Test;
public class WSAClientServerTest extends AbstractWSATestBase {
- static final String PORT = allocatePort(Server.class);
+ static final String PORT = Server.PORT;
+ static final String PORT2 = Server.PORT2;
private final QName serviceName = new QName("http://apache.org/cxf/systest/ws/addr_feature/",
"AddNumbersService");
@@ -144,6 +145,42 @@ public class WSAClientServerTest extends
}
}
+
+ @Test
+ public void testNonAnonSoap12Fault() throws Exception {
+ try {
+ AddNumbersPortType port = getNonAnonPort();
+ ((BindingProvider)port).getRequestContext()
+ .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + PORT2 + "/jaxws/soap12/add");
+ port.addNumbers(1, 2);
+ } catch (SOAPFaultException e) {
+ assertTrue("expected non-anonymous required message",
+ e.getMessage().contains("Found anonymous address but non-anonymous required"));
+ assertTrue("expected sender faultCode", e.getFault().getFaultCode().contains("Sender"));
+ assertTrue("expected OnlyNonAnonymousAddressSupported fault subcode",
+ e.getFault()
+ .getFaultSubcodes()
+ .next()
+ .toString()
+ .contains("{http://www.w3.org/2005/08/addressing}OnlyNonAnonymousAddressSupported"));
+
+ }
+
+ }
+
+
+ private AddNumbersPortType getNonAnonPort() {
+ URL wsdl = getClass().getResource("/wsdl_systest_soap12/add_numbers_soap12.wsdl");
+ assertNotNull("WSDL is null", wsdl);
+
+ AddNumbersService service = new AddNumbersService(wsdl, serviceName);
+ assertNotNull("Service is null ", service);
+ return service.getAddNumbersNonAnonPort(new AddressingFeature());
+ }
+
+
+
private AddNumbersPortType getPort() throws Exception {
URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
assertNotNull("WSDL is null", wsdl);