summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java')
-rw-r--r--sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/Axis2EngineIntegration.java542
-rw-r--r--sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSBindingProviderFactory.java65
-rw-r--r--sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSReferenceBindingProvider.java83
-rw-r--r--sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSServiceBindingProvider.java156
-rw-r--r--sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/TuscanyDispatcher.java104
5 files changed, 950 insertions, 0 deletions
diff --git a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/Axis2EngineIntegration.java b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/Axis2EngineIntegration.java
new file mode 100644
index 0000000000..b466f133af
--- /dev/null
+++ b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/Axis2EngineIntegration.java
@@ -0,0 +1,542 @@
+/*
+ * 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.tuscany.sca.binding.ws.jaxws.axis2;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.Types;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.axis2.deployment.util.Utils;
+import org.apache.axis2.description.AxisEndpoint;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.local.LocalResponder;
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.xsd.XSDefinition;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaExternal;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+public class Axis2EngineIntegration {
+
+ //=========================================================
+ // most of the following is related to rewriting WSDL imports
+ // I'd like to move this but don't know where to yet.
+
+ public static final String IMPORT_TAG = "import";
+ public static final String INCLUDE_TAG = "include";
+
+ public static final QName QNAME_WSA_ADDRESS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_ADDRESS);
+ public static final QName QNAME_WSA_FROM =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM);
+ public static final QName QNAME_WSA_REFERENCE_PARAMETERS =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.EPR_REFERENCE_PARAMETERS);
+
+ //Schema element names
+ public static final String ELEM_SCHEMA = "schema";
+
+ //Schema URI
+ public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema";
+ public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema";
+ public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema";
+
+ //Schema QNames
+ public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA);
+ public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA);
+ public static final List<QName> XSD_QNAME_LIST =
+ Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001});
+
+ //=========================================================
+
+ /*
+ * Create the whole configuration context for the Axis engine
+ */
+ private static class Axis2Config {
+ private ClassLoaderContext classLoaderContext;
+ private URL axis2xmlURL;
+ private URL repositoryURL;
+ }
+
+ // Cache the discovered axis2 configuration but we need to create a new instance of ConfigurationContext every time
+ private static Axis2Config axis2Config;
+
+ public synchronized static ConfigurationContext getAxisConfigurationContext(final ServiceDiscovery serviceDiscovery) {
+
+ // get the axis configuration context from the Tuscany axis2.xml file
+ // Allow privileged access to read properties. Requires PropertyPermission read in
+ // security policy.
+ if (axis2Config == null) {
+ try {
+ axis2Config = AccessController.doPrivileged(new PrivilegedExceptionAction<Axis2Config>() {
+ public Axis2Config run() throws AxisFault, MalformedURLException {
+ // collect together the classloaders that Axis2 requireds in order to load
+ // pluggable items such as the Tuscany MessageReceivers and the xerces
+ // document builder.
+ ClassLoader wsBindingCL = getClass().getClassLoader();
+ ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader();
+ ClassLoader localtransportCL = LocalResponder.class.getClassLoader();
+ ClassLoaderContext classLoaderContext =
+ new ClassLoaderContext(wsBindingCL, axis2CL, localtransportCL);
+
+ classLoaderContext =
+ new ClassLoaderContext(classLoaderContext.getClassLoader(), serviceDiscovery,
+ XMLInputFactory.class, DocumentBuilderFactory.class);
+
+ URL axis2xmlURL =
+ wsBindingCL
+ .getResource("org/apache/tuscany/sca/binding/ws/jaxws/axis2/engine/conf/tuscany-axis2.xml");
+ if (axis2xmlURL != null) {
+ URL repositoryURL = new URL(axis2xmlURL, "../repository/");
+ Axis2Config config = new Axis2Config();
+ config.classLoaderContext = classLoaderContext;
+ config.axis2xmlURL = axis2xmlURL;
+ config.repositoryURL = repositoryURL;
+ return config;
+ } else {
+ return null;
+ }
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new ServiceRuntimeException(e.getException());
+ }
+ }
+
+ if (axis2Config == null) {
+ return null;
+ }
+
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() {
+ public ConfigurationContext run() throws AxisFault {
+ ClassLoader oldTCCL = axis2Config.classLoaderContext.setContextClassLoader();
+ try {
+ ConfigurationContext configurationContext =
+ ConfigurationContextFactory.createConfigurationContextFromURIs(axis2Config.axis2xmlURL,
+ axis2Config.repositoryURL);
+ return configurationContext;
+ } finally {
+ if (oldTCCL != null) {
+ Thread.currentThread().setContextClassLoader(oldTCCL);
+ }
+ }
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw new ServiceRuntimeException(e.getException());
+ }
+
+ }
+
+ //=========================================================
+
+ /**
+ * Create an AxisService from the Java interface class of the SCA service interface
+ */
+ public static AxisService createJavaAxisService(String endpointURL,
+ ConfigurationContext configContext,
+ AbstractContract contract) throws AxisFault {
+ AxisService axisService = new AxisService();
+ String path = URI.create(endpointURL).getPath();
+ axisService.setName(path);
+ axisService.setServiceDescription("Tuscany configured AxisService for service: " + endpointURL);
+ axisService.setClientSide(false);
+ Parameter classParam =
+ new Parameter(Constants.SERVICE_CLASS,
+ ((JavaInterface)contract.getInterfaceContract().getInterface()).getJavaClass().getName());
+ axisService.addParameter(classParam);
+ try {
+ Utils.fillAxisService(axisService, configContext.getAxisConfiguration(), null, null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ return axisService;
+ }
+
+ //=========================================================
+
+ /**
+ * Create an AxisService from the WSDL doc used by ws binding
+ */
+ public static AxisService createWSDLAxisService(String endpointURL,
+ Port port,
+ WebServiceBinding wsBinding) throws AxisFault {
+
+ Definition definition = wsBinding.getWSDLDocument();
+ QName serviceQName = wsBinding.getService().getQName();
+ Definition def = getDefinition(definition, serviceQName);
+
+ final WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(def, serviceQName, port.getName());
+ builder.setServerSide(true);
+ // [rfeng] Add a custom resolver to work around WSCOMMONS-228
+ // TODO - 228 is resolved, is this still required
+ builder.setCustomResolver(new URIResolverImpl(def));
+ builder.setBaseUri(def.getDocumentBaseURI());
+ // [rfeng]
+ // AxisService axisService = builder.populateService();
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ AxisService axisService;
+ try {
+ axisService = AccessController.doPrivileged(new PrivilegedExceptionAction<AxisService>() {
+ public AxisService run() throws AxisFault {
+ return builder.populateService();
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (AxisFault)e.getException();
+ }
+
+ String name = URI.create(endpointURL).getPath();
+ //[nash] HTTP endpoints need a leading slash for WSDL imports to work with ?wsdl
+ if (endpointURL.startsWith("jms")) {
+ name = name.startsWith("/") ? name.substring(1) : name;
+ }
+ axisService.setName(name);
+ axisService.setEndpointURL(endpointURL);
+ axisService.setDocumentation("Tuscany configured AxisService for service: " + endpointURL);
+
+ // TODO - again, do we ever have more than one endpoint
+ // on the service side?
+ for (Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext();) {
+ AxisEndpoint ae = (AxisEndpoint)i.next();
+ if (endpointURL.startsWith("jms")) {
+// not in Axis2 1.5.1
+// Parameter qcf = new Parameter(JMSConstants.CONFAC_PARAM, null);
+// qcf.setValue(DEFAULT_QUEUE_CONNECTION_FACTORY);
+// axisService.addParameter(qcf);
+ break;
+ }
+ }
+
+ // Add schema information to the AxisService (needed for "?xsd=" support)
+ addSchemas(wsBinding.getWSDLDefinition(), axisService);
+
+ // Use the existing WSDL
+ Parameter wsdlParam = new Parameter("wsdl4jDefinition", null);
+ wsdlParam.setValue(definition);
+ axisService.addParameter(wsdlParam);
+ Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
+ axisService.addParameter(userWSDL);
+
+ // Modify schema imports and includes to add "servicename?xsd=" prefix.
+ // Axis2 does this for schema extensibility elements, but Tuscany has
+ // overriden the WSDl4J deserializer to create UnknownExtensibilityElement
+ // elements in place of these.
+ modifySchemaImportsAndIncludes(definition, name);
+
+ // Axis2 1.3 has a bug with returning incorrect values for the port
+ // addresses. To work around this, compute the values here.
+ Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false");
+ axisService.addParameter(modifyAddr);
+
+ return axisService;
+ }
+
+
+ /**
+ * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205
+ */
+ private static Definition getDefinition(Definition definition, QName serviceName) {
+
+ if (serviceName == null) {
+ return definition;
+ }
+
+ if (definition == null) {
+ return null;
+ }
+ Object service = definition.getServices().get(serviceName);
+ if (service != null) {
+ return definition;
+ }
+ for (Object i : definition.getImports().values()) {
+ List<Import> imports = (List<Import>)i;
+ for (Import imp : imports) {
+ Definition d = getDefinition(imp.getDefinition(), serviceName);
+ if (d != null) {
+ return d;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static void addSchemas(WSDLDefinition wsdlDef, AxisService axisService) {
+ for (XSDefinition xsDef : wsdlDef.getXmlSchemas()) {
+ if (xsDef.getSchema() != null) {
+ axisService.addSchema(xsDef.getSchema());
+ updateSchemaRefs(xsDef.getSchema(), axisService.getName());
+ }
+ }
+ for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) {
+ addSchemas(impDef, axisService);
+ }
+ }
+
+ private static void updateSchemaRefs(XmlSchema parentSchema, String name) {
+ for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) {
+ Object obj = iter.next();
+ if (obj instanceof XmlSchemaExternal) {
+ XmlSchemaExternal extSchema = (XmlSchemaExternal)obj;
+ String location = extSchema.getSchemaLocation();
+ if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) {
+ extSchema.setSchemaLocation(name + "?xsd=" + location);
+ }
+ if (extSchema.getSchema() != null) {
+ updateSchemaRefs(extSchema.getSchema(), name);
+ }
+ }
+ }
+ }
+
+ private static void modifySchemaImportsAndIncludes(Definition definition, String name) {
+ // adjust the schema locations in types section
+ Types types = definition.getTypes();
+ if (types != null) {
+ for (Iterator iter = types.getExtensibilityElements().iterator(); iter.hasNext();) {
+ Object ext = iter.next();
+ if (ext instanceof UnknownExtensibilityElement && XSD_QNAME_LIST
+ .contains(((UnknownExtensibilityElement)ext).getElementType())) {
+ changeLocations(((UnknownExtensibilityElement)ext).getElement(), name);
+ }
+ }
+ }
+ for (Iterator iter = definition.getImports().values().iterator(); iter.hasNext();) {
+ Vector values = (Vector)iter.next();
+ for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) {
+ Import wsdlImport = (Import)valuesIter.next();
+ modifySchemaImportsAndIncludes(wsdlImport.getDefinition(), name);
+ }
+ }
+ }
+
+ private static void changeLocations(Element element, String name) {
+ NodeList nodeList = element.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ String tagName = nodeList.item(i).getLocalName();
+ if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) {
+ processImport(nodeList.item(i), name);
+ }
+ }
+ }
+
+ private static void processImport(Node importNode, String name) {
+ NamedNodeMap nodeMap = importNode.getAttributes();
+ for (int i = 0; i < nodeMap.getLength(); i++) {
+ Node attribute = nodeMap.item(i);
+ if (attribute.getNodeName().equals("schemaLocation")) {
+ String location = attribute.getNodeValue();
+ if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) {
+ attribute.setNodeValue(name + "?xsd=" + location);
+ }
+ }
+ }
+ }
+
+ //=========================================================
+
+ /*
+ * Create the service message receivers and the service provider that will push
+ * messages out onto the binding wire
+ */
+/*
+ public static void createAxisServiceProviders(AxisService axisService,
+ RuntimeEndpoint endpoint,
+ WebServiceBinding wsBinding,
+ ExtensionPointRegistry extensionPoints) {
+ for (Iterator<?> i = axisService.getOperations(); i.hasNext();) {
+ AxisOperation axisOp = (AxisOperation)i.next();
+ Operation op = getOperation(axisOp, wsBinding);
+ if (op != null) {
+
+ if (op.isNonBlocking()) {
+ axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
+ } else {
+ axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
+ }
+
+ MessageReceiver msgrec = null;
+ Axis2ServiceProvider serviceProvider = new Axis2ServiceProvider(endpoint, wsBinding, extensionPoints);
+ if (op.isNonBlocking()) {
+ msgrec = new Axis2ServiceInMessageReceiver(serviceProvider, op);
+ } else {
+ msgrec = new Axis2ServiceInOutSyncMessageReceiver(serviceProvider, op);
+ }
+ axisOp.setMessageReceiver(msgrec);
+ }
+ }
+ }
+*/
+
+ private static Operation getOperation(AxisOperation axisOp,WebServiceBinding wsBinding) {
+ String operationName = axisOp.getName().getLocalPart();
+ Interface iface = wsBinding.getBindingInterfaceContract().getInterface();
+ for (Operation op : iface.getOperations()) {
+ if (op.getName().equalsIgnoreCase(operationName)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ //=========================================================
+
+ public static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
+
+ public static void setPortAddress(Port port, String locationURI) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ ((SOAPAddress)ext).setLocationURI(locationURI);
+ }
+ if (ext instanceof SOAP12Address) {
+ ((SOAP12Address)ext).setLocationURI(locationURI);
+ }
+ }
+
+ /**
+ * This method is copied from AxisService.createClientSideAxisService to
+ * work around http://issues.apache.org/jira/browse/WSCOMMONS-228
+ *
+ * @param wsdlDefinition
+ * @param wsdlServiceName
+ * @param portName
+ * @param options
+ * @return
+ * @throws AxisFault
+ */
+ @Deprecated
+ public static AxisService createClientSideAxisService(Definition definition,
+ QName serviceName,
+ String portName,
+ Options options) throws AxisFault {
+ Definition def = getDefinition(definition, serviceName);
+ final WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(def, serviceName, portName);
+ serviceBuilder.setServerSide(false);
+ // [rfeng] Add a custom resolver to work around WSCOMMONS-228
+ serviceBuilder.setCustomResolver(new URIResolverImpl(def));
+ serviceBuilder.setBaseUri(def.getDocumentBaseURI());
+ // [rfeng]
+ // Allow access to read properties. Requires PropertiesPermission in security policy.
+ AxisService axisService;
+ try {
+ axisService = AccessController.doPrivileged(new PrivilegedExceptionAction<AxisService>() {
+ public AxisService run() throws AxisFault {
+ return serviceBuilder.populateService();
+ }
+ });
+ } catch ( PrivilegedActionException e ) {
+ throw (AxisFault) e.getException();
+ }
+
+ AxisEndpoint axisEndpoint = (AxisEndpoint)axisService.getEndpoints().get(axisService.getEndpointName());
+ options.setTo(new EndpointReference(axisEndpoint.getEndpointURL()));
+ if (axisEndpoint != null) {
+ options.setSoapVersionURI((String)axisEndpoint.getBinding().getProperty(WSDL2Constants.ATTR_WSOAP_VERSION));
+ }
+ return axisService;
+ }
+
+ /**
+ * URI resolver implementation for XML schema
+ */
+ public static class URIResolverImpl implements URIResolver {
+ private Definition definition;
+
+ public URIResolverImpl(Definition definition) {
+ this.definition = definition;
+ }
+
+ public org.xml.sax.InputSource resolveEntity(java.lang.String targetNamespace,
+ java.lang.String schemaLocation,
+ java.lang.String baseUri) {
+ try {
+ if (baseUri == null) {
+ baseUri = definition.getDocumentBaseURI();
+ }
+ URL url = new URL(new URL(baseUri), schemaLocation);
+ return XMLDocumentHelper.getInputSource(url);
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSBindingProviderFactory.java b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSBindingProviderFactory.java
new file mode 100644
index 0000000000..2d3e58473f
--- /dev/null
+++ b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSBindingProviderFactory.java
@@ -0,0 +1,65 @@
+/*
+ * 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.tuscany.sca.binding.ws.jaxws.axis2;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHostHelper;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+/**
+ * JAXWSBindingProviderFactory
+ *
+ * @version $Rev: 936193 $ $Date: 2010-04-21 09:08:43 +0100 (Wed, 21 Apr 2010) $
+ */
+
+public class JAXWSBindingProviderFactory implements BindingProviderFactory<WebServiceBinding> {
+
+ private ExtensionPointRegistry extensionPoints;
+ private ServletHost servletHost;
+
+ public JAXWSBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ this.servletHost = ServletHostHelper.getServletHost(extensionPoints);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) {
+ return new JAXWSReferenceBindingProvider(extensionPoints, endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return new JAXWSServiceBindingProvider(extensionPoints, endpoint, servletHost);
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+}
diff --git a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSReferenceBindingProvider.java b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSReferenceBindingProvider.java
new file mode 100644
index 0000000000..f01fc78c7c
--- /dev/null
+++ b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSReferenceBindingProvider.java
@@ -0,0 +1,83 @@
+/*
+ * 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.tuscany.sca.binding.ws.jaxws.axis2;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.jaxws.axis2.Axis2EngineIntegration;
+import org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingInvoker;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Node;
+
+public class JAXWSReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private ExtensionPointRegistry extensionPoints;
+ private javax.xml.soap.MessageFactory messageFactory;
+ private WebServiceBinding wsBinding;
+
+ public JAXWSReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
+ RuntimeEndpointReference endpointReference) {
+
+ this.extensionPoints = extensionPoints;
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ DataBindingExtensionPoint dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+
+ this.messageFactory = modelFactories.getFactory(javax.xml.soap.MessageFactory.class);
+ this.wsBinding = (WebServiceBinding) endpointReference.getBinding();
+
+ // A WSDL document should always be present in the binding
+ if (wsBinding.getWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + endpointReference.getURI());
+ }
+
+ // Set to use the DOM data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ if (contract.getInterface() != null) {
+ contract.getInterface().resetDataBinding(Node.class.getName());
+ }
+ }
+
+ public void start() {
+// ConfigurationContext configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery());
+ }
+
+ public void stop() {
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return new JAXWSBindingInvoker(operation, null, messageFactory, wsBinding);
+ }
+
+}
diff --git a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSServiceBindingProvider.java b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSServiceBindingProvider.java
new file mode 100644
index 0000000000..c32c5964c9
--- /dev/null
+++ b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSServiceBindingProvider.java
@@ -0,0 +1,156 @@
+/*
+ * 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.tuscany.sca.binding.ws.jaxws.axis2;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.Service.Mode;
+
+import org.apache.axis2.jaxws.server.endpoint.EndpointImpl;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.jaxws.JAXWSBindingProvider;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeProperties;
+
+public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+
+ private JAXWSBindingProvider jaxwsBindingProvider;
+
+ private Endpoint wsEndpoint;
+
+ public JAXWSServiceBindingProvider(ExtensionPointRegistry extensionPoints,
+ RuntimeEndpoint endpoint,
+ ServletHost servletHost) {
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ DataBindingExtensionPoint dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+ String defaultPort = "8085";
+ RuntimeProperties ps = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class);
+ String pp = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
+ if (pp != null) {
+ defaultPort = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
+ }
+
+ this.endpoint = endpoint;
+ this.wsBinding = (WebServiceBinding)endpoint.getBinding();
+
+ jaxwsBindingProvider = new JAXWSBindingProvider(endpoint,
+ servletHost,
+ modelFactories,
+ dataBindings,
+ defaultPort);
+ }
+
+ public void start() {
+ // experiment in how to install a JAXWS provider into Axis programmitcally starting
+ // with just using the JAXWS API. This is unlikely to be sufficient as we have to
+ // install policy etc but it's a start
+
+ // create the JAXWS endpoint based on the provider
+ //wsEndpoint = Endpoint.create(SOAPBinding.SOAP11HTTP_BINDING, jaxwsBindingProvider);
+ wsEndpoint = new EndpointImpl(jaxwsBindingProvider);
+
+ // TODO - There is something odd in the way that service name is calculated in
+ // some circumstances
+ // sometimes getServiceName() returns null
+ // sometimes getService().getQName returns a QName namespace that doesn't match the WSDL
+ // sometimes getNamespace() returns null
+ // So here we delve directly into the WSDL4J model as the Tuscany model isn't up to date
+ String targetNamespace = wsBinding.getWSDLDefinition().getDefinition().getTargetNamespace();
+
+ //set up WSDL for Provider
+ List<Source> metadata = new ArrayList<Source>();
+
+ // WSDL DOM seems to be null here so went with writing out
+ // string version of WSDL and reading it back in again
+ //Node node = wsBinding.getWSDLDefinition().getDefinition().getDocumentationElement();
+ //Source source = new DOMSource(node);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ try {
+ WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+ writer.writeWSDL(wsBinding.getWSDLDefinition().getDefinition(), outStream);
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+
+ //System.out.println(outStream.toString());
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ Source source = new StreamSource(inStream);
+ source.setSystemId(targetNamespace);
+
+ metadata.add(source);
+
+ Map<String, Object> properties = new HashMap<String, Object>();
+
+ QName portName = new QName(targetNamespace,
+ wsBinding.getPort().getName());
+ properties.put(Endpoint.WSDL_PORT, portName);
+
+ QName serviceName = new QName(targetNamespace,
+ wsBinding.getService().getQName().getLocalPart());
+ properties.put(Endpoint.WSDL_SERVICE, serviceName);
+
+ wsEndpoint.setMetadata(metadata);
+ wsEndpoint.setProperties(properties);
+
+ // Start up the endpoint
+ wsEndpoint.publish(wsBinding.getURI());
+
+ jaxwsBindingProvider.start();
+
+ }
+
+ public void stop() {
+ jaxwsBindingProvider.stop();
+ wsEndpoint.stop();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+}
diff --git a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/TuscanyDispatcher.java b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/TuscanyDispatcher.java
new file mode 100644
index 0000000000..48e335db20
--- /dev/null
+++ b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/TuscanyDispatcher.java
@@ -0,0 +1,104 @@
+/*
+ * 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.tuscany.sca.binding.ws.jaxws.axis2;
+
+import java.net.URI;
+import java.util.HashMap;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.HandlerDescription;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.RequestURIBasedDispatcher;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A Tuscany specific Axis2 Dispatcher that enables using services
+ * exposed at the SCA defined service URI instead of /services/<serviceName>
+ *
+ * @version $Rev: 917502 $ $Date: 2010-03-01 12:54:07 +0000 (Mon, 01 Mar 2010) $
+ */
+public class TuscanyDispatcher extends RequestURIBasedDispatcher {
+
+ public static final String NAME = "TuscanyDispatcher";
+ private static final Log log = LogFactory.getLog(RequestURIBasedDispatcher.class);
+ private static final boolean isDebugEnabled = log.isDebugEnabled();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.axis2.engine.AbstractDispatcher#findService(org.apache.axis2.context.MessageContext)
+ */
+ @Override
+ public AxisService findService(MessageContext messageContext) throws AxisFault {
+ EndpointReference toEPR = messageContext.getTo();
+
+ if (toEPR != null) {
+ if(isDebugEnabled){
+ log.debug("Checking for Service using target endpoint address : " + toEPR.getAddress());
+ }
+
+ String path = URI.create(toEPR.getAddress()).getPath();
+
+ ConfigurationContext configurationContext = messageContext.getConfigurationContext();
+ AxisConfiguration registry = configurationContext.getAxisConfiguration();
+
+ String serviceName = findAxisServiceName(registry, path);
+ return registry.getService(serviceName);
+
+ } else {
+ if(isDebugEnabled){
+ log.debug("Attempted to check for Service using null target endpoint URI");
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public void initDispatcher() {
+ init(new HandlerDescription(NAME));
+ }
+
+ protected String findAxisServiceName(AxisConfiguration registry, String path) {
+ HashMap services = registry.getServices();
+ if (services == null) {
+ return null;
+ }
+ String[] parts = path.split("/");
+ String serviceName = "";
+ for (int i=parts.length-1; i>=0; i--) {
+ serviceName = parts[i] + serviceName;
+ if (services.containsKey(serviceName)) {
+ return serviceName;
+ }
+ serviceName = "/" + serviceName;
+ if (services.containsKey(serviceName)) {
+ return serviceName;
+ }
+ }
+
+ return null;
+ }
+
+}