Author: barrettj
Date: Tue May 4 00:25:24 2010
New Revision: 940682
URL: http://svn.apache.org/viewvc?rev=940682&view=rev
Log:
Add Addressing support on client side configurable via metadata. Add
associated TDD tests.
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataAddressingFeatureTests.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?rev=940682&r1=940681&r2=940682&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
Tue May 4 00:25:24 2010
@@ -43,6 +43,7 @@ import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.ws.soap.AddressingFeature.Responses;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import java.util.Hashtable;
import java.util.Map;
@@ -122,7 +123,7 @@ public class BindingProvider implements
}
}
- // See if the metadata from creating the service indicates that MTOM
and/or RespectBinding should be enabled
+ // See if the metadata from creating the service indicates that MTOM,
Addressing and/or RespectBinding should be enabled
if (binding instanceof SOAPBinding) {
configureBindingFromMetadata();
}
@@ -159,16 +160,20 @@ public class BindingProvider implements
}
/**
- * Configure the binding from the Metadata for MTOM and RespectBinding.
+ * Configure the binding from the Metadata for WebService Features.
*/
private void configureBindingFromMetadata() {
// MTOM can be enabled either at the ServiceDescription level (via the
WSDL binding type) or
// at the EndpointDescription level via the binding type used to
create a Dispatch.
boolean enableMTOMFromMetadata = false;
int mtomThreshold = 0;
+ boolean isAddressingConfiguredViaMetadata = false;
boolean enableRespectBindingdFromMetadata = false;
+ boolean enableAddressingFromMetadata = false;
+ boolean requireAddressingFromMetadata = false;
+ Responses addressingResponses = null;
- // if we have an SEI for the port, then we'll use it in order to
search for MTOM configuration
+ // if we have an SEI for the port, then we'll use it in order to
search for WebService Feature configuration
if(endpointDesc.getEndpointInterfaceDescription() != null
&&
endpointDesc.getEndpointInterfaceDescription().getSEIClass()
!= null) {
@@ -179,11 +184,24 @@ public class BindingProvider implements
enableRespectBindingdFromMetadata =
isRespectBindingEnabled(endpointDesc.getServiceDescription(), serviceDelegate,
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+
+ isAddressingConfiguredViaMetadata =
isAddressingConfigured(endpointDesc.getServiceDescription(), serviceDelegate,
+
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+ if (isAddressingConfiguredViaMetadata) {
+ enableAddressingFromMetadata =
isAddressingEnabled(endpointDesc.getServiceDescription(), serviceDelegate,
+
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+ requireAddressingFromMetadata =
isAddressingRequired(endpointDesc.getServiceDescription(), serviceDelegate,
+
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+ addressingResponses =
getAddressingResponses(endpointDesc.getServiceDescription(), serviceDelegate,
+
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+ }
+
+
}
else {
enableMTOMFromMetadata =
endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
- // Threshold & RespectBinding does not need to be set here based
on the sparse composite (i.e. depolyment descriptor)
- // since it can only be applied to a port injection (i.e. an SEI)
using a DD.
+ // MTOM.Threshold, RespectBinding, and Addressing does not need to
be set here based on the sparse composite
+ // (i.e. depolyment descriptor) since it can only be applied to a
port injection (i.e. an SEI) using a DD.
}
if (!enableMTOMFromMetadata) {
String bindingType = endpointDesc.getClientBindingID();
@@ -199,6 +217,13 @@ public class BindingProvider implements
if (enableRespectBindingdFromMetadata) {
((SOAPBinding) binding).setRespectBindingEnabled(true);
}
+
+ if (isAddressingConfiguredViaMetadata) {
+ ((SOAPBinding) binding).setAddressingConfigured(true);
+ ((SOAPBinding)
binding).setAddressingEnabled(enableAddressingFromMetadata);
+ ((SOAPBinding)
binding).setAddressingRequired(requireAddressingFromMetadata);
+ ((SOAPBinding)
binding).setAddressingResponses(addressingResponses);
+ }
}
private boolean isRespectBindingEnabled(ServiceDescription
serviceDescription, ServiceDelegate serviceDelegateKey,
@@ -207,6 +232,42 @@ public class BindingProvider implements
return isEnabled;
}
+
+ /**
+ * Answer if addressing was explicitly configured via metadata. Note that
if Addressing was not explicitly configured,
+ * then the related methods will return default values. If Addressing was
explicitly configured, the related
+ * methods will return values based on whatever configuration was
specified.
+ * @see #isAddressingEnabled(ServiceDescription, ServiceDelegate, Class)
+ * @see #isAddressingRequired(ServiceDescription, ServiceDelegate, Class)
+ * @see #getAddressingResponses(ServiceDescription, ServiceDelegate, Class)
+ * @param serviceDescription
+ * @param serviceDelegateKey
+ * @param seiClass
+ * @return true if addressing was explicitly configured via metadata,
false otherwise.
+ */
+ private boolean isAddressingConfigured(ServiceDescription
serviceDescription, ServiceDelegate serviceDelegateKey,
+ Class seiClass) {
+ boolean isConfigured =
serviceDescription.isAddressingConfigured(serviceDelegateKey, seiClass);
+ return isConfigured;
+ }
+
+ private boolean isAddressingEnabled(ServiceDescription serviceDescription,
ServiceDelegate serviceDelegateKey,
+ Class seiClass) {
+ boolean isEnabled =
serviceDescription.isAddressingEnabled(serviceDelegateKey, seiClass);
+ return isEnabled;
+ }
+
+ private boolean isAddressingRequired(ServiceDescription
serviceDescription, ServiceDelegate serviceDelegateKey,
+ Class seiClass) {
+ boolean isRequired =
serviceDescription.isAddressingRequired(serviceDelegateKey, seiClass);
+ return isRequired;
+ }
+ private Responses getAddressingResponses(ServiceDescription
serviceDescription, ServiceDelegate serviceDelegateKey,
+ Class seiClass) {
+ Responses responses =
serviceDescription.getAddressingResponses(serviceDelegateKey, seiClass);
+ return responses;
+ }
+
private int getMTOMThreshold(ServiceDescription serviceDescription,
ServiceDelegate serviceDelegate, Class seiClass) {
int threshold = serviceDescription.getMTOMThreshold(serviceDelegate,
seiClass);
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java?rev=940682&r1=940681&r2=940682&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
Tue May 4 00:25:24 2010
@@ -32,6 +32,8 @@ import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFactory;
import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.AddressingFeature.Responses;
+
import java.util.HashSet;
import java.util.Set;
@@ -45,6 +47,10 @@ public class SOAPBinding extends Binding
private boolean mtomEnabled = false;
private int mtomThreshold = 0;
private boolean respectBindingEnabled = false;
+ private boolean addressingConfigured = false;
+ private boolean addressingEnabled = false;
+ private boolean addressingRequired = false;
+ private Responses addressingResponses = Responses.ALL;
private static Log log = LogFactory.getLog(SOAPBinding.class);
@@ -68,6 +74,67 @@ public class SOAPBinding extends Binding
public void setRespectBindingEnabled(boolean enabled) {
respectBindingEnabled = enabled;
}
+
+ /**
+ * Indicates if Addressing was configured explicitly via metadata, such as
through a deployment descriptor.
+ * If an AddressingAnnot was specified in the DBC, then this will answer
true. The related addressing methods
+ * will return a default value if this method returns false.
+ * @see #isAddressingEnabled()
+ * @see #isAddressingRequired()
+ * @see #getAddressingResponses()
+ * @return true if addressing was explicitly configured via an
AddressingAnnot in the DBC; false otherwise.
+ */
+ public boolean isAddressingConfigured() {
+ return addressingConfigured;
+ }
+
+ /**
+ * Set whether Addressing was explicitly configured via metadata. The
default is false.
+ * @param configured boolean indicating of addressing was configured via
metadata.
+ */
+ public void setAddressingConfigured(boolean configured) {
+ addressingConfigured = configured;
+ }
+
+ /**
+ * Indicates if addressing is enabled or disabled.
+ * Note that if addressing was not explicitly configured via metadata,
this will return a default value.
+ * @see #isAddressingConfigured()
+ * @return true if addressing is enabled, false (default) otherwise.
+ */
+ public boolean isAddressingEnabled() {
+ return addressingEnabled;
+ }
+ public void setAddressingEnabled(boolean enabled) {
+ addressingEnabled = enabled;
+ }
+
+ /**
+ * Indicates if addressing is required or not.
+ * Note that if addressing was not explicitly configured via metadata,
this will return a default value.
+ * @see #isAddressingConfigured()
+ * @return true if addressing is required, false (default) otherwise.
+ */
+ public boolean isAddressingRequired() {
+ return addressingRequired;
+ }
+ public void setAddressingRequired(boolean required) {
+ addressingRequired = required;
+ }
+
+ /**
+ * Return the type of responses required by Addressing.
+ * Note that if addressing was not explicitly configured via metadata,
this will return a default value.
+ * @see #isAddressingConfigured()
+ * @return AddressingFeature.Responses ENUM value indicating what type of
addressing responses are required.
+ */
+ public Responses getAddressingResponses() {
+ return addressingResponses;
+ }
+ public void setAddressingResponses(Responses responses) {
+ addressingResponses = responses;
+ }
+
/*
* (non-Javadoc)
*
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=940682&r1=940681&r2=940682&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 00:25:24 2010
@@ -19,7 +19,9 @@
package org.apache.axis2.jaxws.client.proxy;
+import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.AddressingConstants.Final;
import org.apache.axis2.jaxws.BindingProvider;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.client.async.AsyncResponse;
@@ -265,6 +267,10 @@ public class JAXWSProxyHandler extends B
Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID,
getRequestContext(), request);
+ // Note that configuring the MessageContext for addressing based on
the metadata and for any
+ // WebService Features needs to be done after the application context
migration since it will move properties
+ // from the JAXWS RequestContext onto the Axis2 Message context,
overwritting any that are already set.
+ configureAddressing(request, this);
// Perform the WebServiceFeature configuration requested by the user.
bnd.configure(request, this);
@@ -385,6 +391,44 @@ public class JAXWSProxyHandler extends B
return null;
}
+ /**
+ * For a SOAP Binding, configure the Addressing-related properties on the
message context based on the
+ * addressing configuration specified via metadata (such as a deployment
descriptor). Note that if
+ * addressing was not explicitly configured, then the Addressing-related
propertes will not be set on the
+ * message context.
+ * <p>
+ * This code is similar to the client-side Addressing configurator what
the properties on the message context
+ * are set to.
+ * @see org.apache.axis2.jaxws.client.config.AddressingConfigurator
+ * @param messageContext The message context on which Addressing
properties will be set
+ * @param bindingProvider Instance of the binding provider for which
property values will be determined
+ */
+ private void configureAddressing(MessageContext messageContext,
BindingProvider bindingProvider) {
+
+ Binding binding = (Binding) bindingProvider.getBinding();
+ if (binding != null && binding instanceof SOAPBinding) {
+ SOAPBinding soapBinding = (SOAPBinding) binding;
+ org.apache.axis2.jaxws.binding.SOAPBinding implBinding =
(org.apache.axis2.jaxws.binding.SOAPBinding) soapBinding;
+ if (implBinding.isAddressingConfigured()) {
+ String addressingNamespace =
implBinding.getAddressingNamespace();
+ Boolean disableAddressing = new Boolean(true);
+
+ if (implBinding.isAddressingEnabled()) {
+ addressingNamespace = Final.WSA_NAMESPACE;
+ disableAddressing = new Boolean(false);
+ }
+
+
messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
addressingNamespace);
+
messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
disableAddressing);
+
+ // If the Addressing feature was specified, then get the
responses value from it 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()));
+ }
+ }
+ }
+
private AsyncResponse createProxyListener(Object[] args,
OperationDescription operationDesc) {
ProxyAsyncListener listener = new ProxyAsyncListener(operationDesc);
listener.setHandler(this);
Added:
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=940682&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java
(added)
+++
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/client/proxy/ProxyAddressingMetadataTest.java
Tue May 4 00:25:24 2010
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.client.proxy;
+
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingConstants.Final;
+import org.apache.axis2.jaxws.client.InterceptableClientTestCase;
+import org.apache.axis2.jaxws.client.TestClientInvocationController;
+import org.apache.axis2.jaxws.core.InvocationContext;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.description.builder.AddressingAnnot;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MDQConstants;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.AddressingFeature.Responses;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Validate that addressing can be configured via metadata (such as via a
deployment descriptor)
+ */
+public class ProxyAddressingMetadataTest extends InterceptableClientTestCase {
+
+ /**
+ * Validate when no addressing-related metadata is set.
+ */
+ public void testAddressingNoMetadata() {
+ 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();
+
+ 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);
+
+ assertNull(version);
+ assertTrue(disabled);
+ assertNull(responses);
+ }
+
+ /**
+ * Validate correct behavior when addressing-related metadata is specified
in a sparse composite, such as
+ * would be used to represent configuration via a Deployment Descriptor.
+ */
+ public void testAddressingMetadata() {
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ AddressingAnnot addressingFeature = new AddressingAnnot();
+ addressingFeature.setEnabled(true);
+ 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();
+
+ String version = (String)
request.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+ assertNotNull("Version not set", version);
+ assertEquals("Wrong addressing version", Final.WSA_NAMESPACE, version);
+
+ Boolean disabled = (Boolean)
request.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
+ assertNotNull("Disabled not set", disabled);
+ assertFalse("Addressing disabled", disabled);
+
+ 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 {
+
+ public String doSomething(String id);
+
+ }
+
+}
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataAddressingFeatureTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataAddressingFeatureTests.java?rev=940682&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataAddressingFeatureTests.java
(added)
+++
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataAddressingFeatureTests.java
Tue May 4 00:25:24 2010
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.spi;
+
+import org.apache.axis2.jaxws.binding.SOAPBinding;
+import org.apache.axis2.jaxws.description.builder.AddressingAnnot;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MDQConstants;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.AddressingFeature.Responses;
+
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Validate the setting up of the Addressing WebServiceFeature on the client
side via meta-data
+ * (such as a deployment descriptor)
+ */
+public class ClientMetadataAddressingFeatureTests extends TestCase {
+ static final String namespaceURI =
"http://description.jaxws.axis2.apache.org";
+ static final String svcLocalPart = "svcLocalPart";
+ static final String multiPortWsdl = "ClientMetadataMultiPort.wsdl";
+
+ public void testAddressingEnabled() {
+ Service service = createService();
+ ClientMetadataAddressingPortSEI port =
service.getPort(ClientMetadataAddressingPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("Addressing is not configured",
soapBinding.isAddressingConfigured());
+ assertTrue("Addressing is not enabled",
soapBinding.isAddressingEnabled());
+ }
+
+ public void testAddressingDisabled() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ AddressingAnnot addressingFeature = new AddressingAnnot();
+ addressingFeature.setEnabled(false);
+ wsFeatures.add(addressingFeature);
+ map.put(ClientMetadataAddressingPortSEI.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+ ClientMetadataAddressingPortSEI port =
service.getPort(ClientMetadataAddressingPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("Addressing is not configured",
soapBinding.isAddressingConfigured());
+ assertFalse("Addressing is enabled",
soapBinding.isAddressingEnabled());
+ }
+
+ public void testAddressingRequired() {
+ Service service = createService();
+ ClientMetadataAddressingPortSEI port =
service.getPort(ClientMetadataAddressingPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("Addressing is not configured",
soapBinding.isAddressingConfigured());
+ assertTrue("Addressing is not required",
soapBinding.isAddressingRequired());
+ }
+
+ public void testAddressingNotRequired() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ AddressingAnnot addressingFeature = new AddressingAnnot();
+ addressingFeature.setEnabled(true);
+ addressingFeature.setRequired(false);
+ wsFeatures.add(addressingFeature);
+ map.put(ClientMetadataAddressingPortSEI.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+ ClientMetadataAddressingPortSEI port =
service.getPort(ClientMetadataAddressingPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("Addressing is not configured",
soapBinding.isAddressingConfigured());
+ assertFalse("Addressing is required",
soapBinding.isAddressingRequired());
+ }
+
+ public void testAddressingResponses() {
+ Service service = createService();
+ ClientMetadataAddressingPortSEI port =
service.getPort(ClientMetadataAddressingPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("Addressing is not configured",
soapBinding.isAddressingConfigured());
+ assertEquals("Addressing Responses incorrect",
Responses.NON_ANONYMOUS, soapBinding.getAddressingResponses());
+ }
+
+ public void testDefaultAddressingValues() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Service service = Service.create(wsdlUrl, serviceQName);
+ ClientMetadataAddressingPortSEI port =
service.getPort(ClientMetadataAddressingPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertFalse("Addressing is configured",
soapBinding.isAddressingConfigured());
+ assertFalse("Addressing is enabled",
soapBinding.isAddressingEnabled());
+ assertFalse("Addressing is required",
soapBinding.isAddressingRequired());
+ assertEquals("Addressing responses incorrect", Responses.ALL,
soapBinding.getAddressingResponses());
+ }
+
+ /**
+ * Create a service as would be done via injection or lookup, including a
sparse composite that
+ * contains features (as might be set by a deployment descriptor).
+ *
+ * @return a Service created as done via injection or lookup.
+ */
+ private Service createService() {
+ // Even for a port injection or lookup, the service will also be
treated as an injection or lookup
+ // So we need to setup the sparse DBC to create the service
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ AddressingAnnot addressingFeature = new AddressingAnnot();
+ addressingFeature.setEnabled(true);
+ addressingFeature.setRequired(true);
+ addressingFeature.setResponses(Responses.NON_ANONYMOUS);
+ wsFeatures.add(addressingFeature);
+ map.put(ClientMetadataAddressingPortSEI.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+ return service;
+ }
+
+ @WebService(name="EchoMessagePortType",
targetNamespace="http://description.jaxws.axis2.apache.org")
+ interface ClientMetadataAddressingPortSEI {
+ public String echoMessage(String string);
+ }
+}
\ No newline at end of file
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?rev=940682&r1=940681&r2=940682&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
Tue May 4 00:25:24 2010
@@ -26,6 +26,8 @@ import org.apache.axis2.jaxws.descriptio
import javax.xml.namespace.QName;
import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.soap.AddressingFeature.Responses;
+
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -237,4 +239,50 @@ public interface ServiceDescription {
*/
public abstract boolean isRespectBindingEnabled(Object serviceDelegateKey,
Class seiClass);
+ /**
+ * Answer whether Addressing was explicitly configured via metadata (such
as a deployment descriptor) on the
+ * service-requester. Note that the related methods will return default
values if Addressing was not explicitly
+ * configured; otherwise they will return values set based on the metadata
configuration.
+ * @see #isAddressingEnabled(Object, Class)
+ * @see #isAddressingRequired(Object, Class)
+ * @see #getAddressingResponses(Object, Class)
+ * @param serviceDelegateKey The instance of the service delegate related
to this service
+ * @param seiClass The SEI for the port to retrieve the setting for.
+ * @return true if Addressing was explicitly set via metadata, false
otherwise.
+ */
+ public abstract boolean isAddressingConfigured(Object serviceDelegateKey,
Class seiClass);
+
+ /**
+ * Answer whether Addressing is enabled on the service-requester.
+ * Note that if addressing was not configured via metadata, then this
method will return a default value,
+ * otherwise it will return the value configured via metadata.
+ * @see #isAddressingConfigured(Object, Class)
+ * @param serviceDelegateKey The instance of the service delegate related
to this service
+ * @param seiClass The SEI for the port to retrieve the setting for.
+ * @return true if Addressing is enabled on the service-requester, false
(default) otherwise
+ */
+ public abstract boolean isAddressingEnabled(Object serviceDelegateKey,
Class seiClass);
+
+ /**
+ * Answer whether Addressing is required on the service-requester.
+ * Note that if addressing was not configured via metadata, then this
method will return a default value,
+ * otherwise it will return the value configured via metadata.
+ * @see #isAddressingConfigured(Object, Class)
+ * @param serviceDelegateKey The instance of the service delegate related
to this service
+ * @param seiClass The SEI for the port to retrieve the setting for.
+ * @return true if Addressing is required on the service-requester, false
(default) otherwise
+ */
+ public abstract boolean isAddressingRequired(Object serviceDelegateKey,
Class seiClass);
+
+ /**
+ * Answer the type of Addressing responses required by the
service-requester.
+ * Note that if addressing was not configured via metadata, then this
method will return a default value,
+ * otherwise it will return the value configured via metadata.
+ * @see #isAddressingConfigured(Object, Class)
+ * @param serviceDelegateKey The instance of the service delegate related
to this service
+ * @param seiClass The SEI for the port to retrieve the setting for.
+ * @return AddressingFeature.Responses vale corresponding to the type of
responses required by service-requester.
+ */
+ public abstract Responses getAddressingResponses(Object
serviceDelegateKey, Class seiClass);
+
}
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=940682&r1=940681&r2=940682&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Tue May 4 00:25:24 2010
@@ -21,7 +21,6 @@ package org.apache.axis2.jaxws.descripti
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.ClientConfigurationFactory;
@@ -36,6 +35,7 @@ import org.apache.axis2.jaxws.descriptio
import org.apache.axis2.jaxws.description.ServiceDescriptionJava;
import org.apache.axis2.jaxws.description.ServiceDescriptionWSDL;
import org.apache.axis2.jaxws.description.ServiceRuntimeDescription;
+import org.apache.axis2.jaxws.description.builder.AddressingAnnot;
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.MDQConstants;
import org.apache.axis2.jaxws.description.builder.MTOMAnnot;
@@ -69,6 +69,8 @@ import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.PortInfo;
import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.AddressingFeature.Responses;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -2962,4 +2964,79 @@ public class ServiceDescriptionImpl
}
return enabled;
}
+
+ public boolean isAddressingConfigured(Object serviceDelegateKey, Class
seiClass) {
+ boolean configured = false;
+ List<Annotation> seiFeatureList =
getSEIFeatureList(serviceDelegateKey, seiClass);
+ if (log.isDebugEnabled()) {
+ log.debug("Feature list for delegate: " + serviceDelegateKey + ",
and SEI: " + seiClass
+ + ", is: " + seiFeatureList);
+ }
+ if (seiFeatureList != null) {
+ for (int i = 0; i < seiFeatureList.size(); i++) {
+ Annotation checkAnnotation = seiFeatureList.get(i);
+ if (checkAnnotation instanceof AddressingAnnot) {
+ AddressingAnnot addressingAnnot = (AddressingAnnot)
checkAnnotation;
+ configured = true;
+ }
+ }
+ }
+ return configured;
+ }
+
+ public boolean isAddressingEnabled(Object serviceDelegateKey, Class
seiClass) {
+ boolean enabled = false;
+ List<Annotation> seiFeatureList =
getSEIFeatureList(serviceDelegateKey, seiClass);
+ if (log.isDebugEnabled()) {
+ log.debug("Feature list for delegate: " + serviceDelegateKey + ",
and SEI: " + seiClass
+ + ", is: " + seiFeatureList);
+ }
+ if (seiFeatureList != null) {
+ for (int i = 0; i < seiFeatureList.size(); i++) {
+ Annotation checkAnnotation = seiFeatureList.get(i);
+ if (checkAnnotation instanceof AddressingAnnot) {
+ AddressingAnnot addressingAnnot = (AddressingAnnot)
checkAnnotation;
+ enabled = addressingAnnot.enabled();
+ }
+ }
+ }
+ return enabled;
+ }
+ public boolean isAddressingRequired(Object serviceDelegateKey, Class
seiClass) {
+ boolean enabled = false;
+ List<Annotation> seiFeatureList =
getSEIFeatureList(serviceDelegateKey, seiClass);
+ if (log.isDebugEnabled()) {
+ log.debug("Feature list for delegate: " + serviceDelegateKey + ",
and SEI: " + seiClass
+ + ", is: " + seiFeatureList);
+ }
+ if (seiFeatureList != null) {
+ for (int i = 0; i < seiFeatureList.size(); i++) {
+ Annotation checkAnnotation = seiFeatureList.get(i);
+ if (checkAnnotation instanceof AddressingAnnot) {
+ AddressingAnnot addressingAnnot = (AddressingAnnot)
checkAnnotation;
+ enabled = addressingAnnot.required();
+ }
+ }
+ }
+ return enabled;
+ }
+ public Responses getAddressingResponses(Object serviceDelegateKey, Class
seiClass) {
+ Responses responses = null;
+ List<Annotation> seiFeatureList =
getSEIFeatureList(serviceDelegateKey, seiClass);
+ if (log.isDebugEnabled()) {
+ log.debug("Feature list for delegate: " + serviceDelegateKey + ",
and SEI: " + seiClass
+ + ", is: " + seiFeatureList);
+ }
+ if (seiFeatureList != null) {
+ for (int i = 0; i < seiFeatureList.size(); i++) {
+ Annotation checkAnnotation = seiFeatureList.get(i);
+ if (checkAnnotation instanceof AddressingAnnot) {
+ AddressingAnnot addressingAnnot = (AddressingAnnot)
checkAnnotation;
+ responses = addressingAnnot.responses();
+ }
+ }
+ }
+ return responses;
+ }
+
}