Author: barrettj Date: Tue May 4 23:44:34 2010 New Revision: 941108 URL: http://svn.apache.org/viewvc?rev=941108&view=rev Log: Add client-side enablement for AddressingFeature.required set via AddressingFeature on the factory methods or via metadata. Update associated tests.
Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingFeatureTest.java axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java?rev=941108&r1=941107&r2=941108&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java Tue May 4 23:44:34 2010 @@ -60,6 +60,7 @@ public class AddressingConfigurator impl String addressingNamespace = bnd.getAddressingNamespace(); Boolean disableAddressing = (Boolean) messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); + String addressingRequired = AddressingConstants.ADDRESSING_UNSPECIFIED; //Figure out which WS-Addressing feature was specified causing this configurator to run. if (addressingFeature != null && submissionAddressingFeature != null) { @@ -75,6 +76,9 @@ public class AddressingConfigurator impl addressingNamespace = Final.WSA_NAMESPACE; disableAddressing = Boolean.FALSE; + if (addressingFeature.isRequired() || submissionAddressingFeature.isRequired()) { + addressingRequired = AddressingConstants.ADDRESSING_REQUIRED; + } } else if (w3cAddressingEnabled) { //Enable only 2005/08 addressing @@ -85,6 +89,9 @@ public class AddressingConfigurator impl } addressingNamespace = Final.WSA_NAMESPACE; disableAddressing = Boolean.FALSE; + if (addressingFeature.isRequired()) { + addressingRequired = AddressingConstants.ADDRESSING_REQUIRED; + } } else if (submissionAddressingEnabled) { //Enable only 2004/08 addressing @@ -95,6 +102,9 @@ public class AddressingConfigurator impl } addressingNamespace = Submission.WSA_NAMESPACE; disableAddressing = Boolean.FALSE; + if (submissionAddressingFeature.isRequired()) { + addressingRequired = AddressingConstants.ADDRESSING_REQUIRED; + } } else { //Disable 2005/08 and 2004/08 addressing @@ -114,6 +124,9 @@ public class AddressingConfigurator impl } addressingNamespace = Final.WSA_NAMESPACE; disableAddressing = Boolean.FALSE; + if (addressingFeature.isRequired()) { + addressingRequired = AddressingConstants.ADDRESSING_REQUIRED; + } } else { //Disable 2005/08 addressing @@ -133,6 +146,9 @@ public class AddressingConfigurator impl } addressingNamespace = Submission.WSA_NAMESPACE; disableAddressing = Boolean.FALSE; + if (submissionAddressingFeature.isRequired()) { + addressingRequired = AddressingConstants.ADDRESSING_REQUIRED; + } } else { //Disable 2004/08 addressing @@ -167,6 +183,7 @@ public class AddressingConfigurator impl messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, addressingNamespace); messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, disableAddressing); + messageContext.setProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER, addressingRequired); // If the Addressing feature was specified, then get the responses value from it and map to the value // the addressing handler expects Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?rev=941108&r1=941107&r2=941108&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Tue May 4 23:44:34 2010 @@ -412,17 +412,21 @@ public class JAXWSProxyHandler extends B if (implBinding.isAddressingConfigured()) { String addressingNamespace = implBinding.getAddressingNamespace(); Boolean disableAddressing = new Boolean(true); + String addressingRequired = AddressingConstants.ADDRESSING_UNSPECIFIED; if (implBinding.isAddressingEnabled()) { addressingNamespace = Final.WSA_NAMESPACE; disableAddressing = new Boolean(false); + if (implBinding.isAddressingRequired()) { + addressingRequired = AddressingConstants.ADDRESSING_REQUIRED; + } } messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, addressingNamespace); messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, disableAddressing); + messageContext.setProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER, addressingRequired); - // If the Addressing feature was specified, then get the responses value from it and map to the value - // the addressing handler expects + // Get the responses value and map to the value the addressing handler expects messageContext.setProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME, org.apache.axis2.jaxws.server.config.AddressingConfigurator.mapResponseAttributeToAddressing(implBinding.getAddressingResponses())); } Modified: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingFeatureTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingFeatureTest.java?rev=941108&r1=941107&r2=941108&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingFeatureTest.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingFeatureTest.java Tue May 4 23:44:34 2010 @@ -86,10 +86,12 @@ public class ProxyAddressingFeatureTest String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); String responses = (String) request.getProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME); + String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER); assertNull(version); assertTrue(disabled); assertNull(responses); + assertNull(required); org.apache.axis2.context.MessageContext axis2Request = request.getAxisMessageContext(); @@ -119,10 +121,12 @@ public class ProxyAddressingFeatureTest String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); String responses = (String) request.getProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME); + String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER); assertEquals(Final.WSA_NAMESPACE, version); assertFalse(disabled); assertEquals("Wrong default responses", AddressingConstants.WSAM_INVOCATION_PATTERN_BOTH, responses); + assertEquals("Wrong required attribute", AddressingConstants.ADDRESSING_UNSPECIFIED, required); org.apache.axis2.context.MessageContext axis2Request = request.getAxisMessageContext(); @@ -153,10 +157,12 @@ public class ProxyAddressingFeatureTest String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); - + String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER); + assertEquals(Final.WSA_NAMESPACE, version); assertTrue(disabled); - + assertEquals("Wrong required attribute", AddressingConstants.ADDRESSING_UNSPECIFIED, required); + org.apache.axis2.context.MessageContext axis2Request = request.getAxisMessageContext(); org.apache.axis2.addressing.EndpointReference epr = Modified: axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java?rev=941108&r1=941107&r2=941108&view=diff ============================================================================== --- axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java (original) +++ axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java Tue May 4 23:44:34 2010 @@ -62,10 +62,12 @@ public class ProxyAddressingMetadataTest String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); String responses = (String) request.getProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME); + String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER); assertNull(version); assertTrue(disabled); assertNull(responses); + assertNull(required); } /** @@ -98,6 +100,11 @@ public class ProxyAddressingMetadataTest String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); assertNotNull("Version not set", version); assertEquals("Wrong addressing version", Final.WSA_NAMESPACE, version); + + String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER); + assertNotNull("Required not set", required); + assertEquals("Wrong addressing required", AddressingConstants.ADDRESSING_REQUIRED, required); + Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); assertNotNull("Disabled not set", disabled); @@ -109,6 +116,53 @@ public class ProxyAddressingMetadataTest } + /** + * Validate correct behavior when addressing is disabled via addressing-related metadata specified in a sparse composite, such as + * would be used to represent configuration via a Deployment Descriptor. + */ + public void testAddressingMetadataDisabled() { + Map<String, List<Annotation>> map = new HashMap(); + ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>(); + AddressingAnnot addressingFeature = new AddressingAnnot(); + addressingFeature.setEnabled(false); + addressingFeature.setRequired(true); + addressingFeature.setResponses(Responses.NON_ANONYMOUS); + wsFeatures.add(addressingFeature); + map.put(ProxyAddressingService.class.getName(), wsFeatures); + DescriptionBuilderComposite serviceDBC = new DescriptionBuilderComposite(); + serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map); + ServiceDelegate.setServiceMetadata(serviceDBC); + + Service svc = Service.create(new QName("http://test", "ProxyAddressingService")); + ProxyAddressingService proxy = svc.getPort(ProxyAddressingService.class); + assertNotNull(proxy); + + proxy.doSomething("12345"); + + TestClientInvocationController testController = getInvocationController(); + InvocationContext ic = testController.getInvocationContext(); + MessageContext request = ic.getRequestMessageContext(); + + // If addressing is not enabled the version should not be set + String version = (String) request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION); + assertNull("Version set", version); + + Boolean disabled = (Boolean) request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES); + assertNotNull("Disabled not set", disabled); + assertTrue("Addressing disabled", disabled); + + // Even though required=true above, per the addressing developers, they want to leave it set as unspecified when + // addressing is not enabled. + String required = (String) request.getProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER); + assertNotNull("Required not set", required); + assertEquals("Wrong addressing required", AddressingConstants.ADDRESSING_UNSPECIFIED, required); + + String responses = (String) request.getProperty(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME); + assertNotNull("Responses not set", responses); + assertEquals("Wrong responses value", AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS, responses); + + } + @WebService() public interface ProxyAddressingService {