summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/JAXWSBindingProvider.java114
-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.java22
-rw-r--r--sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/axis2/engine/conf/tuscany-axis2.xml2
3 files changed, 128 insertions, 10 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/JAXWSBindingProvider.java b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/axis2/JAXWSBindingProvider.java
new file mode 100644
index 0000000000..6e3b821af7
--- /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/JAXWSBindingProvider.java
@@ -0,0 +1,114 @@
+/*
+ * 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 javax.annotation.Resource;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.DetailEntry;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Provider;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.Service.Mode;
+
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+
+@WebServiceProvider
+@ServiceMode(Mode.MESSAGE)
+public class JAXWSBindingProvider implements Provider<SOAPMessage> {
+ private MessageFactory messageFactory;
+ private RuntimeEndpoint endpoint;
+ private WebServiceBinding wsBinding;
+ private javax.xml.soap.MessageFactory soapMessageFactory;
+ private SOAPFactory soapFactory;
+
+ @Resource
+ private WebServiceContext context;
+
+
+ public SOAPMessage invoke(SOAPMessage request) {
+ try {
+ // Assuming document-literal-wrapper style
+ Node root = request.getSOAPBody().getFirstChild();
+ String operationName = root.getLocalName();
+ Operation operation = null;
+ for (InvocationChain invocationChain : endpoint.getInvocationChains()) {
+ if (operationName.equals(invocationChain.getSourceOperation().getName())) {
+ operation = invocationChain.getSourceOperation();
+ break;
+ }
+ }
+ if (operation == null) {
+ throw new SOAPException("Operation not found: " + operationName);
+ }
+
+ Message requestMsg = messageFactory.createMessage();
+ Object[] body = new Object[]{root};
+ requestMsg.setBody(body);
+ requestMsg.setOperation(operation);
+
+ Message responseMsg = endpoint.invoke(operation, requestMsg);
+
+ SOAPMessage response = soapMessageFactory.createMessage();
+ if (responseMsg.isFault()) {
+// ServiceRuntimeException e = responseMsg.getBody();
+// throw e;
+
+ FaultException fe = responseMsg.getBody();
+ SOAPFault fault = response.getSOAPBody().addFault(new QName(response.getSOAPBody().getNamespaceURI(), "Server"), fe.getMessage());
+ Detail d = fault.addDetail();
+ DetailEntry de = d.addDetailEntry(fe.getFaultName());
+ SOAPElement dece = de.addChildElement("message");
+ if (fe.getMessage() != null) {
+ dece.addTextNode(fe.getMessage());
+ }
+
+ } else {
+ Element element = responseMsg.getBody();
+ response.getSOAPBody().addChildElement(soapFactory.createElement(element));
+ }
+ return response;
+ } catch (SOAPException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+}
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
index e5f297c9fc..2aa2cc5db2 100644
--- 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
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.sca.binding.ws.jaxws.axis2;
+import java.net.URI;
import java.util.HashMap;
import java.util.List;
@@ -37,7 +38,6 @@ import org.apache.axis2.jaxws.description.builder.WebServiceProviderAnnot;
import org.apache.axis2.jaxws.description.builder.converter.JavaClassToDBCConverter;
import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
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;
@@ -141,16 +141,19 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
defaultPort = ps.getProperties().getProperty(this.getClass().getName() + ".defaultPort");
}
// ========
-
+/*
jaxwsBindingProvider = new JAXWSBindingProvider(endpoint,
servletHost,
modelFactories,
dataBindings,
defaultPort);
-
+*/
+ jaxwsBindingProvider = new JAXWSBindingProvider();
+
// get the Axis configuration context
configContext = Axis2EngineIntegration.getAxisConfigurationContext(extensionPoints.getServiceDiscovery());
- configContext.setContextRoot(servletHost.getContextPath());
+ //configContext.setContextRoot(servletHost.getContextPath());
+ configContext.setContextRoot("http://localhost:8085");
}
public void start() {
@@ -176,7 +179,7 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
// adjust the service description to match the service we're actually exposing
DescriptionBuilderComposite dbc = dbcMap.values().iterator().next();
dbc.setWebServiceProviderAnnot(webServiceProviderAnnot);
- dbc.setWsdlDefinition(wsBinding.getWSDLDefinition().getDefinition());
+ dbc.setWsdlDefinition(wsBinding.getService().getQName(), wsBinding.getWSDLDefinition().getDefinition());
List<ServiceDescription> serviceDescList = DescriptionFactoryImpl.createServiceDescriptionFromDBCMap(dbcMap, configContext);
ServiceDescription sd = null;
if (serviceDescList != null && serviceDescList.size() > 0) {
@@ -185,13 +188,14 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
// get the first endpoint
EndpointDescription endpointDesc = sd.getEndpointDescriptions_AsCollection().iterator().next();
- //Binding binding = BindingUtils.createBinding(endpointDesc);
+ Binding binding = BindingUtils.createBinding(endpointDesc);
// Add the service into the configuration context
AxisService axisService = endpointDesc.getAxisService();
- axisService.setName(endpointURI);
+ String path = URI.create(endpointURI).getPath();
+ axisService.setName(path);
axisService.setServiceDescription("Tuscany configured AxisService for service: " + deployedURI);
- axisService.setClientSide(false);
+ axisService.setClientSide(false);
configContext.getAxisConfiguration().addService(axisService);
// fire up the Axis servlet
@@ -271,7 +275,7 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider {
*/
public void stop() {
- jaxwsBindingProvider.stop();
+ //jaxwsBindingProvider.stop();
wsEndpoint.stop();
}
diff --git a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/axis2/engine/conf/tuscany-axis2.xml b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/axis2/engine/conf/tuscany-axis2.xml
index 61b4eb4877..40e433e2f8 100644
--- a/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/axis2/engine/conf/tuscany-axis2.xml
+++ b/sca-java-2.x/contrib/modules/binding-ws-runtime-jaxws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/jaxws/axis2/engine/conf/tuscany-axis2.xml
@@ -420,7 +420,7 @@
<!-- Added by Tuscany -->
<handler name="TuscanyDispatcher"
- class="org.apache.tuscany.sca.binding.ws.jaxws.axis2.TuscanyDispatcher">
+ class="org.apache.tuscany.sca.binding.ws.jaxws.axis2.Axis2Dispatcher">
<order phase="Transport"/>
</handler>