Author: ema Date: Wed May 29 08:57:40 2013 New Revision: 1487409 URL: http://svn.apache.org/r1487409 Log: Merged revisions 1487404 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
................ r1487404 | ema | 2013-05-29 16:37:52 +0800 (Wed, 29 May 2013) | 16 lines Merged revisions 1487391 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes ................ r1487391 | ema | 2013-05-29 16:07:50 +0800 (Wed, 29 May 2013) | 9 lines 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.5.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_soap12/ - copied from r1487404, cxf/branches/2.6.x-fixes/systests/ws-specs/src/test/resources/wsdl_systest_soap12/ Modified: cxf/branches/2.5.x-fixes/ (props changed) cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java cxf/branches/2.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java cxf/branches/2.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java Propchange: cxf/branches/2.5.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/branches/2.7.x-fixes:r1487391 Merged /cxf/trunk:r1487389 Merged /cxf/branches/2.6.x-fixes:r1487404 Propchange: cxf/branches/2.5.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=1487409&r1=1487408&r2=1487409&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original) +++ cxf/branches/2.5.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Wed May 29 08:57:40 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; @@ -464,11 +466,27 @@ public class MAPAggregator extends Abstr 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")); } 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")); @@ -573,6 +591,13 @@ public class MAPAggregator extends Abstr // 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))); @@ -1285,5 +1310,15 @@ public class MAPAggregator extends Abstr 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.5.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.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java?rev=1487409&r1=1487408&r2=1487409&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java (original) +++ cxf/branches/2.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/Server.java Wed May 29 08:57:40 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() { ep.stop(); @@ -55,4 +72,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.5.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.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java?rev=1487409&r1=1487408&r2=1487409&view=diff ============================================================================== --- cxf/branches/2.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java (original) +++ cxf/branches/2.5.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java Wed May 29 08:57:40 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"); @@ -143,6 +144,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);
