You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2006/04/30 10:55:50 UTC
svn commit: r398299 - in
/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2:
assembly/ assembly/impl/ builder/ config/ handler/ loader/ util/
Author: antelder
Date: Sun Apr 30 01:55:47 2006
New Revision: 398299
URL: http://svn.apache.org/viewcvs?rev=398299&view=rev
Log:
Move Axis2 binding over to simplified extension APIs and build as much as possible up front rather than on each request
Added:
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSEntryPointContextFactory.java
- copied, changed from r398254, incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointContextFactory.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSExternalServiceContextFactory.java
- copied, changed from r398254, incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceContextFactory.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2OperationInvoker.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2ServiceInvoker.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceInvoker.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceTargetInvoker.java
Removed:
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceContextFactory.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointContextFactory.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceClient.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalWebServiceTargetInvoker.java
Modified:
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilder.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointBuilder.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceBindingLoader.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/DataBinding.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/SDODataBinding.java
incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/WebServiceBinding.java Sun Apr 30 01:55:47 2006
@@ -19,8 +19,9 @@
import javax.wsdl.Definition;
import javax.wsdl.Port;
-import org.apache.tuscany.model.assembly.Binding;
import org.apache.tuscany.common.resource.ResourceLoader;
+import org.apache.tuscany.model.assembly.Binding;
+
import commonj.sdo.helper.TypeHelper;
/**
@@ -30,8 +31,9 @@
/**
* Set the URI of the WSDL port for this binding.
- *
- * @param portURI the URI of the WSDL port
+ *
+ * @param portURI
+ * the URI of the WSDL port
*/
void setPortURI(String portURI);
@@ -42,6 +44,7 @@
/**
* Returns the WSDL definition containing the WSDL port.
+ *
* @return the WSDL definition containing the WSDL port
*/
Definition getWSDLDefinition();
@@ -53,6 +56,7 @@
/**
* Sets the WSDL definition containing the WSDL port.
+ *
* @param definition
*/
void setWSDLDefinition(Definition definition);
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/assembly/impl/WebServiceBindingImpl.java Sun Apr 30 01:55:47 2006
@@ -24,9 +24,10 @@
import javax.wsdl.Service;
import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
+import org.apache.tuscany.common.resource.ResourceLoader;
import org.apache.tuscany.model.assembly.AssemblyContext;
import org.apache.tuscany.model.assembly.impl.BindingImpl;
-import org.apache.tuscany.common.resource.ResourceLoader;
+
import commonj.sdo.helper.TypeHelper;
/**
@@ -35,9 +36,13 @@
public class WebServiceBindingImpl extends BindingImpl implements WebServiceBinding {
private Definition definition;
+
private Port port;
+
private String portURI;
+
private TypeHelper typeHelper;
+
private ResourceLoader resourceLoader;
/**
@@ -92,7 +97,8 @@
}
/**
- * @param portURI The portURI to set.
+ * @param portURI
+ * The portURI to set.
*/
public void setPortURI(String portURI) {
this.portURI = portURI;
@@ -114,15 +120,14 @@
String portName = portURI.substring(h + 1);
// Load the WSDL definitions for the given namespace
- List<Definition> definitions = modelContext.getAssemblyLoader()
- .loadDefinitions(portNamespace);
+ List<Definition> definitions = modelContext.getAssemblyLoader().loadDefinitions(portNamespace);
if (definitions == null) {
throw new IllegalArgumentException("Cannot find WSDL definition for " + portNamespace);
}
for (Definition def : definitions) {
// Find the port with the given name
- for (Service service : (Collection<Service>)def.getServices().values()) {
+ for (Service service : (Collection<Service>) def.getServices().values()) {
Port prt = service.getPort(portName);
if (prt != null) {
this.definition = def;
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilder.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilder.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilder.java Sun Apr 30 01:55:47 2006
@@ -16,15 +16,27 @@
*/
package org.apache.tuscany.binding.axis2.builder;
-import commonj.sdo.helper.TypeHelper;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+
import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContextConstants;
import org.apache.axis2.description.AxisService;
import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
-import org.apache.tuscany.binding.axis2.config.ExternalWebServiceContextFactory;
-import org.apache.tuscany.binding.axis2.handler.ExternalWebServiceClient;
+import org.apache.tuscany.binding.axis2.config.WSExternalServiceContextFactory;
+import org.apache.tuscany.binding.axis2.handler.Axis2OperationInvoker;
+import org.apache.tuscany.binding.axis2.handler.Axis2ServiceInvoker;
import org.apache.tuscany.binding.axis2.handler.WebServicePortMetaData;
+import org.apache.tuscany.binding.axis2.util.DataBinding;
+import org.apache.tuscany.binding.axis2.util.SDODataBinding;
import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
import org.apache.tuscany.core.builder.BuilderConfigException;
import org.apache.tuscany.core.builder.impl.ExternalServiceContextFactory;
@@ -32,63 +44,93 @@
import org.apache.tuscany.core.injection.SingletonObjectFactory;
import org.apache.tuscany.model.assembly.Binding;
import org.apache.tuscany.model.assembly.ExternalService;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.soap.SOAPFactory;
import org.osoa.sca.annotations.Scope;
-import javax.xml.namespace.QName;
-
+import commonj.sdo.helper.TypeHelper;
/**
* Creates a <code>ContextFactory</code> for an external service configured with the {@link WebServiceBinding}
- *
- * @version $Rev$ $Date$
*/
@Scope("MODULE")
public class ExternalWebServiceBuilder extends ExternalServiceBuilderSupport {
+ @Override
protected boolean handlesBindingType(Binding binding) {
return binding instanceof WebServiceBinding;
}
- protected ExternalServiceContextFactory createExternalServiceContextFactory(
- ExternalService externalService) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.core.extension.ExternalServiceBuilderSupport#createExternalServiceContextFactory(org.apache.tuscany.model.assembly.ExternalService)
+ */
+ @Override
+ protected ExternalServiceContextFactory createExternalServiceContextFactory(ExternalService externalService) {
+
+ WebServiceBinding wsBinding = (WebServiceBinding) externalService.getBindings().get(0);
+ Definition wsdlDefinition = wsBinding.getWSDLDefinition();
+ WebServicePortMetaData wsPortMetaData = new WebServicePortMetaData(wsdlDefinition, wsBinding.getWSDLPort(), wsBinding.getURI(), false);
+
+ ServiceClient serviceClient = createServiceClient(externalService.getName(), wsdlDefinition, wsPortMetaData);
+
+ TypeHelper typeHelper = wsBinding.getTypeHelper();
+ Class serviceInterface = externalService.getConfiguredService().getPort().getServiceContract().getInterface();
+ Map<String, Axis2OperationInvoker> invokers = createOperationInvokers(serviceInterface, typeHelper, wsPortMetaData);
+
+ Axis2ServiceInvoker axis2Client = new Axis2ServiceInvoker(serviceClient, invokers);
- ExternalWebServiceClient externalWebServiceClient = createExternalWebServiceClient(externalService);
+ return new WSExternalServiceContextFactory(externalService.getName(), new SingletonObjectFactory<Axis2ServiceInvoker>(axis2Client));
- return new ExternalWebServiceContextFactory(externalService.getName(),
- new SingletonObjectFactory<ExternalWebServiceClient>(externalWebServiceClient));
}
/**
- * Create an ExternalWebServiceClient for the WebServiceBinding
+ * Create an Axis2 ServiceClient configured for the externalService
*/
- private ExternalWebServiceClient createExternalWebServiceClient(ExternalService externalService) {
- // TODO: Review should there be a single global Axis ConfigurationContext
+ protected ServiceClient createServiceClient(String externalServiceName, Definition wsdlDefinition, WebServicePortMetaData wsPortMetaData) {
+
TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator(null, null);
ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
- WebServiceBinding wsBinding = (WebServiceBinding) externalService.getBindings().get(0);
-
- WebServicePortMetaData wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition(),
- wsBinding.getWSDLPort(),
- wsBinding.getURI(),
- false);
QName serviceQName = wsPortMetaData.getServiceName();
String portName = wsPortMetaData.getPortName().getLocalPart();
- AxisService axisService;
+ ServiceClient serviceClient;
try {
- axisService = AxisService.createClientSideAxisService(wsBinding.getWSDLDefinition(),
- serviceQName,
- portName,
- new Options());
+
+ AxisService axisService = AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
+ serviceClient = new ServiceClient(configurationContext, axisService);
+
} catch (AxisFault e) {
BuilderConfigException bce = new BuilderConfigException("AxisFault creating external service", e);
- bce.addContextName(externalService.getName());
+ bce.addContextName(externalServiceName);
throw bce;
}
- TypeHelper typeHelper = wsBinding.getTypeHelper();
- return new ExternalWebServiceClient(configurationContext, axisService, wsPortMetaData, typeHelper);
+ return serviceClient;
+ }
+
+ /**
+ * Create and configure an Axis2OperationInvoker for each operation in the externalService
+ */
+ protected Map<String, Axis2OperationInvoker> createOperationInvokers(Class sc, TypeHelper typeHelper, WebServicePortMetaData wsPortMetaData) {
+ SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+ String serviceNS = wsPortMetaData.getServiceName().getNamespaceURI();
+ Map<String, Axis2OperationInvoker> invokers = new HashMap<String, Axis2OperationInvoker>();
+
+ for (Method m : sc.getMethods()) {
+ String methodName = m.getName();
+ QName wsdlOperationName = new QName(serviceNS, wsPortMetaData.getWSDLOperationName(methodName));
+ DataBinding dataBinding = new SDODataBinding(typeHelper, wsdlOperationName);
+ Options options = new Options();
+ options.setTo(new EndpointReference(wsPortMetaData.getEndpoint()));
+ options.setProperty(MessageContextConstants.CHUNKED, Boolean.FALSE); // TODO: don't do this for wrapped style
+ Axis2OperationInvoker invoker = new Axis2OperationInvoker(wsdlOperationName, options, dataBinding, soapFactory);
+ invokers.put(methodName, invoker);
+ }
+
+ return invokers;
}
}
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceWireBuilder.java Sun Apr 30 01:55:47 2006
@@ -16,25 +16,29 @@
*/
package org.apache.tuscany.binding.axis2.builder;
-import org.apache.tuscany.binding.axis2.config.ExternalWebServiceContextFactory;
-import org.apache.tuscany.binding.axis2.handler.ExternalWebServiceTargetInvoker;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.binding.axis2.config.WSExternalServiceContextFactory;
+import org.apache.tuscany.binding.axis2.handler.ExternalServiceTargetInvoker;
import org.apache.tuscany.core.context.QualifiedName;
import org.apache.tuscany.core.context.ScopeContext;
import org.apache.tuscany.core.extension.WireBuilderSupport;
import org.apache.tuscany.core.wire.TargetInvoker;
import org.osoa.sca.annotations.Scope;
-import java.lang.reflect.Method;
-
@Scope("MODULE")
public class ExternalWebServiceWireBuilder extends WireBuilderSupport {
+ public ExternalWebServiceWireBuilder() {
+ }
+
+ @Override
protected boolean handlesTargetType(Class targetType) {
- return ExternalWebServiceContextFactory.class.isAssignableFrom(targetType);
+ return WSExternalServiceContextFactory.class.isAssignableFrom(targetType);
}
- protected TargetInvoker createInvoker(QualifiedName targetName, Method operation,
- ScopeContext context, boolean downScope) {
- return new ExternalWebServiceTargetInvoker(targetName, operation, context);
+ @Override
+ protected TargetInvoker createInvoker(QualifiedName targetName, Method operation, ScopeContext context, boolean downScope) {
+ return new ExternalServiceTargetInvoker(targetName, operation, context);
}
}
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointBuilder.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointBuilder.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/builder/WebServiceEntryPointBuilder.java Sun Apr 30 01:55:47 2006
@@ -17,7 +17,7 @@
package org.apache.tuscany.binding.axis2.builder;
import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding;
-import org.apache.tuscany.binding.axis2.config.WebServiceEntryPointContextFactory;
+import org.apache.tuscany.binding.axis2.config.WSEntryPointContextFactory;
import org.apache.tuscany.core.builder.impl.EntryPointContextFactory;
import org.apache.tuscany.core.extension.EntryPointBuilderSupport;
import org.apache.tuscany.core.message.MessageFactory;
@@ -25,11 +25,9 @@
import org.apache.tuscany.model.assembly.EntryPoint;
import org.osoa.sca.annotations.Scope;
-
/**
- * Creates a <code>ContextFactory</code> for an entry point configured with the
- * {@link WebServiceBinding}
- *
+ * Creates a <code>ContextFactory</code> for an entry point configured with the {@link WebServiceBinding}
+ *
* @version $Rev$ $Date$
*/
@Scope("MODULE")
@@ -39,9 +37,8 @@
return binding instanceof WebServiceBinding;
}
- protected EntryPointContextFactory createEntryPointContextFactory(EntryPoint entryPoint,
- MessageFactory msgFactory) {
- return new WebServiceEntryPointContextFactory(entryPoint.getName(),messageFactory);
+ protected EntryPointContextFactory createEntryPointContextFactory(EntryPoint entryPoint, MessageFactory msgFactory) {
+ return new WSEntryPointContextFactory(entryPoint.getName(), messageFactory);
}
}
Copied: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSEntryPointContextFactory.java (from r398254, incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointContextFactory.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSEntryPointContextFactory.java?p2=incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSEntryPointContextFactory.java&p1=incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointContextFactory.java&r1=398254&r2=398299&rev=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WebServiceEntryPointContextFactory.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSEntryPointContextFactory.java Sun Apr 30 01:55:47 2006
@@ -20,15 +20,14 @@
import org.apache.tuscany.core.message.MessageFactory;
/**
- * Creates instances of {@link org.apache.tuscany.core.context.EntryPointContext}
- * configured with the appropriate wire chains and bindings. This implementation
- * serves as a marker for
- *
+ * Creates instances of {@link org.apache.tuscany.core.context.EntryPointContext} configured with the appropriate wire chains and bindings. This
+ * implementation serves as a marker for
+ *
* @version $Rev$ $Date$
*/
-public class WebServiceEntryPointContextFactory extends EntryPointContextFactory {
+public class WSEntryPointContextFactory extends EntryPointContextFactory {
- public WebServiceEntryPointContextFactory(String name,MessageFactory messageFactory) {
+ public WSEntryPointContextFactory(String name, MessageFactory messageFactory) {
super(name, messageFactory);
}
Copied: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSExternalServiceContextFactory.java (from r398254, incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceContextFactory.java)
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSExternalServiceContextFactory.java?p2=incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSExternalServiceContextFactory.java&p1=incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceContextFactory.java&r1=398254&r2=398299&rev=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/ExternalWebServiceContextFactory.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/config/WSExternalServiceContextFactory.java Sun Apr 30 01:55:47 2006
@@ -20,16 +20,14 @@
import org.apache.tuscany.core.builder.impl.ExternalServiceContextFactory;
/**
- * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext}
- * configured with the appropriate wire chains and bindings. This implementation serves
- * as a marker for
- * {@link org.apache.tuscany.binding.axis2.builder.ExternalWebServiceWireBuilder}
+ * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext} configured with the appropriate wire chains and bindings. This
+ * implementation serves as a marker for {@link org.apache.tuscany.binding.axis2.builder.ExternalWebServiceWireBuilder}
*
* @version $Rev$ $Date$
*/
-public class ExternalWebServiceContextFactory extends ExternalServiceContextFactory {
+public class WSExternalServiceContextFactory extends ExternalServiceContextFactory {
- public ExternalWebServiceContextFactory(String name, ObjectFactory objectFactory) {
+ public WSExternalServiceContextFactory(String name, ObjectFactory objectFactory) {
super(name, objectFactory);
}
Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2OperationInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2OperationInvoker.java?rev=398299&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2OperationInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2OperationInvoker.java Sun Apr 30 01:55:47 2006
@@ -0,0 +1,99 @@
+/**
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.binding.axis2.handler;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.binding.axis2.util.DataBinding;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.soap.SOAPBody;
+import org.apache.ws.commons.soap.SOAPEnvelope;
+import org.apache.ws.commons.soap.SOAPFactory;
+import org.apache.wsdl.WSDLConstants;
+
+/**
+ * Axis2OperationInvoker uses an Axis2 OperationClient to invoke a remote web service
+ */
+public class Axis2OperationInvoker {
+
+ public QName wsdlOperationName;
+
+ public Options options;
+
+ public DataBinding dataBinding;
+
+ private SOAPFactory soapFactory;
+
+ public Axis2OperationInvoker(QName wsdlOperationName, Options options, DataBinding dataBinding, SOAPFactory soapFactory) {
+ this.wsdlOperationName = wsdlOperationName;
+ this.options = options;
+ this.dataBinding = dataBinding;
+ this.soapFactory = soapFactory;
+ }
+
+ /**
+ * Invoke a WS operation
+ *
+ * @param operationClient
+ * @param args
+ * @return
+ * @throws AxisFault
+ */
+ protected Object invokeOperation(OperationClient operationClient, Object[] args) throws AxisFault {
+
+ operationClient.setOptions(options);
+
+ OMElement requestOM = dataBinding.toOMElement(args);
+
+ SOAPEnvelope env = soapFactory.createSOAPEnvelope();
+ SOAPBody body = soapFactory.createSOAPBody();
+ body.addChild(requestOM);
+ env.setFirstChild(body);
+
+ MessageContext requestMC = new MessageContext();
+ requestMC.setEnvelope(env);
+
+ operationClient.addMessageContext(requestMC);
+
+ operationClient.execute(true);
+
+ MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ OMElement responseOM = responseMC.getEnvelope().getBody().getFirstElement();
+
+ Object[] os = dataBinding.fromOMElement(responseOM);
+
+ Object response;
+ if (os == null || os.length < 1) {
+ response = null;
+ } else {
+ response = os[0];
+ }
+
+ return response;
+ }
+
+ /**
+ * Get the WSDL operation name that this can invoke
+ */
+ public QName getWSDLOperationName() {
+ return wsdlOperationName;
+ }
+
+}
Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2ServiceInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2ServiceInvoker.java?rev=398299&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2ServiceInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/Axis2ServiceInvoker.java Sun Apr 30 01:55:47 2006
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.binding.axis2.handler;
+
+import java.util.Map;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.client.ServiceClient;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * Axis2ServiceInvoker uses Axis2 to invoke a remote web service
+ */
+public class Axis2ServiceInvoker implements ExternalServiceInvoker {
+
+ private ServiceClient serviceClient;
+
+ private Map<String, Axis2OperationInvoker> operationInvokers;
+
+ public Axis2ServiceInvoker(ServiceClient serviceClient, Map<String, Axis2OperationInvoker> operationInvokers) {
+ this.serviceClient = serviceClient;
+ this.operationInvokers = operationInvokers;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.tuscany.binding.axis2.handler.ExternalServiceInvoker#invoke(java.lang.String, java.lang.Object[])
+ */
+ public Object invoke(String methodName, Object[] args) {
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ try {
+
+ Axis2OperationInvoker invoker = operationInvokers.get(methodName);
+
+ // Axis2 operationClients can not be shared so create a new one for each request
+ OperationClient operationClient = serviceClient.createClient(invoker.getWSDLOperationName());
+
+ return invoker.invokeOperation(operationClient, args);
+
+ } catch (AxisFault e) {
+ throw new ServiceRuntimeException(e);
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(ccl);
+ }
+ }
+
+}
Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceInvoker.java?rev=398299&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceInvoker.java Sun Apr 30 01:55:47 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.binding.axis2.handler;
+
+public interface ExternalServiceInvoker {
+
+ public Object invoke(String methodName, Object[] args);
+
+}
Added: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceTargetInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceTargetInvoker.java?rev=398299&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/ExternalServiceTargetInvoker.java Sun Apr 30 01:55:47 2006
@@ -0,0 +1,122 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.binding.axis2.handler;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.context.ExternalServiceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.wire.Interceptor;
+import org.apache.tuscany.core.wire.TargetInvoker;
+
+/**
+ * Responsible for invoking an external service
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExternalServiceTargetInvoker implements TargetInvoker {
+
+ private QualifiedName serviceName;
+
+ private String esName;
+
+ private Method method;
+
+ private ScopeContext container;
+
+ private ExternalServiceContext context;
+
+ /**
+ * Constructs a new ExternalWebServiceTargetInvoker.
+ *
+ * @param container
+ */
+ public ExternalServiceTargetInvoker(QualifiedName serviceName, Method method, ScopeContext container) {
+ assert serviceName != null : "No service name specified";
+ assert method != null : "No method specified";
+ assert container != null : "No scope container specified";
+ this.serviceName = serviceName;
+ this.esName = serviceName.getPartName();
+ this.method = method;
+ this.container = container;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ if (context == null) {
+ Context iContext = container.getContext(esName);
+ if (!(iContext instanceof ExternalServiceContext)) {
+ TargetException te = new TargetException("Unexpected target context type");
+ te.setIdentifier(iContext.getClass().getName());
+ te.addContextName(iContext.getName());
+ throw te;
+ }
+ context = (ExternalServiceContext) iContext;
+ }
+
+ ExternalServiceInvoker invoker = (ExternalServiceInvoker) context.getHandler();
+ if (payload != null) {
+ return doInvoke(invoker, (Object[]) payload);
+ } else {
+ return doInvoke(invoker, null);
+ }
+ }
+
+ protected Object doInvoke(ExternalServiceInvoker invoker, Object[] args) {
+ return invoker.invoke(method.getName(), args);
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setBody(e);
+ }
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ ExternalServiceTargetInvoker invoker = (ExternalServiceTargetInvoker) super.clone();
+ invoker.container = container;
+ invoker.context = this.context;
+ invoker.esName = this.esName;
+ invoker.method = this.method;
+ invoker.serviceName = this.serviceName;
+ return invoker;
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ return null;
+ }
+ }
+
+}
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointInOutSyncMessageReceiver.java Sun Apr 30 01:55:47 2006
@@ -69,9 +69,9 @@
InvocationTargetException, SOAPProcessingException, AxisFault {
OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
- Object[] request = dataBinding.processRequest(requestOM);
+ Object[] request = dataBinding.fromOMElement(requestOM);
Object response = operationMethod.invoke(entryPointProxy, request);
- OMElement responseOM = dataBinding.processResponse(response);
+ OMElement responseOM = dataBinding.toOMElement(new Object[] { response });
SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
soapEnvelope.getBody().addChild(responseOM);
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceEntryPointServlet.java Sun Apr 30 01:55:47 2006
@@ -156,7 +156,7 @@
return m;
}
// tolerate WSDL with capatalized operation name
- StringBuffer sb = new StringBuffer(operationName);
+ StringBuilder sb = new StringBuilder(operationName);
sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
if (m.getName().equals(sb.toString())) {
return m;
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServiceOperationMetaData.java Sun Apr 30 01:55:47 2006
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Set;
+
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
@@ -38,21 +39,29 @@
/**
* Metadata for a WSDL operation
- *
+ *
*/
public class WebServiceOperationMetaData {
// WSDL Binding and BindingOperation
private Binding binding;
+
private BindingOperation bindingOperation;
// Fields to cache derived metadata
private transient Set<Part> inputHeaderParts;
+
private transient Set<Part> outputHeaderParts;
+
private transient String style;
+
private transient String use;
+
private transient String soapAction;
+
private transient List<Object> signature;
+
private String encoding;
+
private transient QName rpcOperationName;
public WebServiceOperationMetaData(Binding binding, BindingOperation bindingOperation) {
@@ -60,12 +69,8 @@
this.bindingOperation = bindingOperation;
}
- public WebServiceOperationMetaData(Binding binding,
- BindingOperation bindingOperation,
- String style,
- String use,
- String encoding,
- String soapAction) {
+ public WebServiceOperationMetaData(Binding binding, BindingOperation bindingOperation, String style, String use, String encoding,
+ String soapAction) {
this.binding = binding;
this.bindingOperation = bindingOperation;
this.style = style;
@@ -138,16 +143,13 @@
public String getStyle() {
if (style == null) {
- SOAPOperation soapOperation = (SOAPOperation)WebServicePortMetaData
- .getExtensibilityElement(bindingOperation.getExtensibilityElements(),
- SOAPOperation.class);
+ SOAPOperation soapOperation = (SOAPOperation) WebServicePortMetaData.getExtensibilityElement(bindingOperation.getExtensibilityElements(),
+ SOAPOperation.class);
if (soapOperation != null) {
style = soapOperation.getStyle();
}
if (style == null) {
- SOAPBinding soapBinding = WebServicePortMetaData
- .getExtensibilityElement(binding.getExtensibilityElements(),
- SOAPBinding.class);
+ SOAPBinding soapBinding = WebServicePortMetaData.getExtensibilityElement(binding.getExtensibilityElements(), SOAPBinding.class);
if (soapBinding != null) {
style = soapBinding.getStyle();
}
@@ -161,16 +163,14 @@
/**
* Returns the SOAP action for the given operation.
- *
+ *
* @param wsdlBindingOperation
* @return
*/
public String getSOAPAction() {
if (soapAction == null) {
final List wsdlBindingOperationExtensions = bindingOperation.getExtensibilityElements();
- final SOAPOperation soapOp = WebServicePortMetaData
- .getExtensibilityElement(wsdlBindingOperationExtensions,
- SOAPOperation.class);
+ final SOAPOperation soapOp = WebServicePortMetaData.getExtensibilityElement(wsdlBindingOperationExtensions, SOAPOperation.class);
if (soapOp != null) {
soapAction = soapOp.getSoapActionURI();
}
@@ -181,8 +181,7 @@
public QName getRPCOperationName() {
if (rpcOperationName == null) {
javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
- String ns = (soapBody != null) ? soapBody.getNamespaceURI()
- : binding.getPortType().getQName().getNamespaceURI();
+ String ns = (soapBody != null) ? soapBody.getNamespaceURI() : binding.getPortType().getQName().getNamespaceURI();
String name = bindingOperation.getOperation().getName();
rpcOperationName = new QName(ns, name);
}
@@ -198,9 +197,9 @@
for (Iterator i = parts.iterator(); i.hasNext();) {
Object part = i.next();
if (part instanceof String) {
- names.add((String)part);
+ names.add((String) part);
} else if (part instanceof Part) {
- names.add(((Part)part).getName());
+ names.add(((Part) part).getName());
}
}
return names;
@@ -227,15 +226,14 @@
}
elements = bindingOutput.getExtensibilityElements();
}
- javax.wsdl.extensions.soap.SOAPBody soapBody = WebServicePortMetaData
- .getExtensibilityElement(elements,
- javax.wsdl.extensions.soap.SOAPBody.class);
+ javax.wsdl.extensions.soap.SOAPBody soapBody = WebServicePortMetaData.getExtensibilityElement(elements,
+ javax.wsdl.extensions.soap.SOAPBody.class);
return soapBody;
}
/**
* Returns the use attribute
- *
+ *
* @param wsdlOperation
* @return
*/
@@ -257,7 +255,7 @@
if (encoding == null) {
javax.wsdl.extensions.soap.SOAPBody soapBody = getSOAPBody(true);
if (soapBody != null) {
- List<String> styles = (List<String>)soapBody.getEncodingStyles();
+ List<String> styles = (List<String>) soapBody.getEncodingStyles();
if (styles != null && !styles.isEmpty()) {
encoding = styles.get(0);
}
@@ -268,7 +266,7 @@
}
return encoding;
}
-
+
public boolean isDocLitWrapped() {
boolean flag = getStyle().equals("document") && getUse().equals("literal");
if (!flag) {
@@ -291,30 +289,19 @@
}
/*
- public SOAPMediator createMediator(boolean serverMode)
- throws SOAPException {
- // create a new mediator for each invoke for thread-safety
- boolean rpcStyle = getStyle().equals("rpc");
- boolean rpcEncoded = isEncoded();
-
- SOAPMediator mediator = null;
-
- if (!rpcStyle) {
- // Document
- mediator = new SOAPDocumentLiteralMediatorImpl(this, serverMode);
- } else {
- if (!rpcEncoded)
- mediator = new SOAPRPCLiteralMediatorImpl(this, serverMode); // RPC-literal
- else
- mediator = new SOAPRPCEncodedMediatorImpl(this, serverMode); // RPC-encoded
- }
- return mediator;
- }
- */
+ * public SOAPMediator createMediator(boolean serverMode) throws SOAPException { // create a new mediator for each invoke for thread-safety
+ * boolean rpcStyle = getStyle().equals("rpc"); boolean rpcEncoded = isEncoded();
+ *
+ * SOAPMediator mediator = null;
+ *
+ * if (!rpcStyle) { // Document mediator = new SOAPDocumentLiteralMediatorImpl(this, serverMode); } else { if (!rpcEncoded) mediator = new
+ * SOAPRPCLiteralMediatorImpl(this, serverMode); // RPC-literal else mediator = new SOAPRPCEncodedMediatorImpl(this, serverMode); // RPC-encoded }
+ * return mediator; }
+ */
/**
* Get the operation signature from the WSDL operation
- *
+ *
* @param wsdlBinding
* @param bindingOperation
* @return
@@ -338,36 +325,26 @@
if ("rpc".equals(sstyle)) {
Collection partNames = input.getMessage().getParts().values();
for (Iterator i = partNames.iterator(); i.hasNext();) {
- Part part = (Part)i.next();
+ Part part = (Part) i.next();
signature.add(part.getName());
}
} else {
/*
- * WS-I Basic Profile 1.1 4.7.6 Operation Signatures
- * Definition: operation signature
- *
- * The profile defines the "operation signature" to be the
- * fully qualified name of the child element of SOAP body of
- * the SOAP input message described by an operation in a
- * WSDL binding.
- *
- * In the case of rpc-literal binding, the operation name is
- * used as a wrapper for the part accessors. In the
- * document-literal case, since a wrapper with the operation
- * name is not present, the message signatures must be
- * correctly designed so that they meet this requirement.
- *
- * An endpoint that supports multiple operations must
- * unambiguously identify the operation being invoked based
- * on the input message that it receives. This is only
- * possible if all the operations specified in the
- * wsdl:binding associated with an endpoint have a unique
- * operation signature.
- *
- * R2710 The operations in a wsdl:binding in a DESCRIPTION
- * MUST result in operation signatures that are different
- * from one another.
- */
+ * WS-I Basic Profile 1.1 4.7.6 Operation Signatures Definition: operation signature
+ *
+ * The profile defines the "operation signature" to be the fully qualified name of the child element of SOAP body of the SOAP input
+ * message described by an operation in a WSDL binding.
+ *
+ * In the case of rpc-literal binding, the operation name is used as a wrapper for the part accessors. In the document-literal case,
+ * since a wrapper with the operation name is not present, the message signatures must be correctly designed so that they meet this
+ * requirement.
+ *
+ * An endpoint that supports multiple operations must unambiguously identify the operation being invoked based on the input message
+ * that it receives. This is only possible if all the operations specified in the wsdl:binding associated with an endpoint have a
+ * unique operation signature.
+ *
+ * R2710 The operations in a wsdl:binding in a DESCRIPTION MUST result in operation signatures that are different from one another.
+ */
List<String> bodyParts = getSOAPBodyParts(true);
Collection<?> parts = input.getMessage().getParts().values();
@@ -450,8 +427,9 @@
/**
* Get a list of indexes for each part in the SOAP body
- *
- * @param isInput TODO
+ *
+ * @param isInput
+ * TODO
* @return
*/
public List<Integer> getBodyPartIndexes(boolean isInput) {
@@ -486,11 +464,11 @@
}
/**
- * Get the corresponding index for a part in the SOAP header by element
- * name
- *
+ * Get the corresponding index for a part in the SOAP header by element name
+ *
* @param elementName
- * @param isInput TODO
+ * @param isInput
+ * TODO
* @return
*/
public int getHeaderPartIndex(QName elementName, boolean isInput) {
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/handler/WebServicePortMetaData.java Sun Apr 30 01:55:47 2006
@@ -36,40 +36,47 @@
/**
* Metadata for a WSDL port
- *
+ *
*/
public class WebServicePortMetaData {
-
+
private Service wsdlService;
+
private QName wsdlServiceName;
+
private Port wsdlPort;
+
private Binding wsdlBinding;
+
private QName wsdlPortName;
+
private PortType wsdlPortType;
+
private QName wsdlPortTypeName;
+
private String endpoint;
+
private boolean managed;
+
private List<WebServiceOperationMetaData> allOperationMetaData;
+
private WSDLServiceContract interfaceType;
/**
* Constructor
- *
+ *
* @param wsdlDefinition
* @param portName
*/
- public WebServicePortMetaData(Definition wsdlDefinition,
- Port wsdlPort,
- String endpoint,
- boolean managed) {
+ public WebServicePortMetaData(Definition wsdlDefinition, Port wsdlPort, String endpoint, boolean managed) {
// Lookup the named port
this.wsdlPort = wsdlPort;
wsdlPortName = new QName(wsdlDefinition.getTargetNamespace(), wsdlPort.getName());
-
+
Collection services = wsdlDefinition.getServices().values();
for (Object serviceObj : services) {
- Service service = (Service)serviceObj;
+ Service service = (Service) serviceObj;
if (service.getPorts().containsValue(wsdlPort)) {
wsdlService = service;
wsdlServiceName = service.getQName();
@@ -99,7 +106,7 @@
/**
* Constructor
- *
+ *
* @param serviceName
* @param portName
* @param portType
@@ -162,7 +169,7 @@
/**
* Returns the endpoint of a given port.
- *
+ *
* @param wsdlPort
* @return
*/
@@ -179,7 +186,7 @@
for (Iterator i = wsdlPortExtensions.iterator(); i.hasNext();) {
final Object extension = i.next();
if (extension instanceof SOAPAddress) {
- return ((SOAPAddress)extension).getLocationURI();
+ return ((SOAPAddress) extension).getLocationURI();
}
}
}
@@ -189,6 +196,7 @@
/**
* Returns the SOAP binding style.
+ *
* @return
*/
public String getStyle() {
@@ -197,8 +205,7 @@
String style = null;
if (wsdlBinding != null) {
final List wsdlBindingExtensions = wsdlBinding.getExtensibilityElements();
- SOAPBinding soapBinding = getExtensibilityElement(wsdlBindingExtensions,
- SOAPBinding.class);
+ SOAPBinding soapBinding = getExtensibilityElement(wsdlBindingExtensions, SOAPBinding.class);
if (soapBinding != null) {
style = soapBinding.getStyle();
}
@@ -210,6 +217,7 @@
/**
* Returns the use attribute
+ *
* @return
*/
public String getUse() {
@@ -219,6 +227,7 @@
/**
* Returns the encoding attribute
+ *
* @return
*/
public String getEncoding() {
@@ -235,6 +244,7 @@
/**
* Returns the first extensibility element of the given type.
+ *
* @param elements
* @param type
* @return
@@ -251,6 +261,7 @@
/**
* Returns the extensibility elements of the given type.
+ *
* @param elements
* @param type
* @return
@@ -268,76 +279,73 @@
/**
* Get the operation signature from the SOAP Body
+ *
* @param body
* @return A list of QNames
*/
-// public static List getOperationSignature(javax.xml.soap.SOAPBody body) {
-// List signature = new ArrayList();
-// for (Iterator i = body.getChildElements(); i.hasNext();) {
-// Object child = i.next();
-// if (child instanceof SOAPBodyElement) {
-// Name name = ((SOAPBodyElement) child).getElementName();
-// QName qname = new QName(name.getURI(), name.getLocalName(), name.getPrefix());
-// signature.add(qname);
-// }
-// }
-// return signature;
-// }
-
-// public static List getRPCOperationSignature(javax.xml.soap.SOAPBody body) {
-// List signature = new ArrayList();
-// for (Iterator i = body.getChildElements(); i.hasNext();) {
-// Object child = i.next();
-// if (child instanceof SOAPBodyElement) {
-// SOAPBodyElement op = ((SOAPBodyElement) child);
-// for (Iterator j = op.getChildElements(); j.hasNext();) {
-// Object part = i.next();
-// if (part instanceof SOAPElement) {
-// SOAPElement p = (SOAPElement) part;
-// signature.add(p.getLocalName());
-// }
-// }
-// }
-// }
-// return signature;
-// }
-
-// public WebServiceOperationMetaData getOperationMetaData(javax.xml.soap.SOAPBody body) {
-// List s1 = getOperationSignature(body);
-// // List rpcParts = getRPCOperationSignature(body);
-// for (Iterator it = getAllOperationMetaData().iterator(); it.hasNext();) {
-// WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) it.next();
-//
-// String style = descriptor.getStyle();
-//
-// if (style.equals("document")) {
-// List s2 = descriptor.getOperationSignature();
-// if (s1.equals(s2))
-// return descriptor;
-// } else {
-// QName op1 = (QName) s1.get(0);
-// QName op2 = descriptor.getRPCOperationName();
-// if (op1.equals(op2)) {
-// /*
-// * // FIXME: [rfeng] We don't support method overloading
-// * List partNames = getOperationSignature(binding,
-// * bindingOperation); if (rpcParts.equals(partNames))
-// */
-// return descriptor;
-// }
-// }
-// }
-// return null;
-// }
-
+ // public static List getOperationSignature(javax.xml.soap.SOAPBody body) {
+ // List signature = new ArrayList();
+ // for (Iterator i = body.getChildElements(); i.hasNext();) {
+ // Object child = i.next();
+ // if (child instanceof SOAPBodyElement) {
+ // Name name = ((SOAPBodyElement) child).getElementName();
+ // QName qname = new QName(name.getURI(), name.getLocalName(), name.getPrefix());
+ // signature.add(qname);
+ // }
+ // }
+ // return signature;
+ // }
+ // public static List getRPCOperationSignature(javax.xml.soap.SOAPBody body) {
+ // List signature = new ArrayList();
+ // for (Iterator i = body.getChildElements(); i.hasNext();) {
+ // Object child = i.next();
+ // if (child instanceof SOAPBodyElement) {
+ // SOAPBodyElement op = ((SOAPBodyElement) child);
+ // for (Iterator j = op.getChildElements(); j.hasNext();) {
+ // Object part = i.next();
+ // if (part instanceof SOAPElement) {
+ // SOAPElement p = (SOAPElement) part;
+ // signature.add(p.getLocalName());
+ // }
+ // }
+ // }
+ // }
+ // return signature;
+ // }
+ // public WebServiceOperationMetaData getOperationMetaData(javax.xml.soap.SOAPBody body) {
+ // List s1 = getOperationSignature(body);
+ // // List rpcParts = getRPCOperationSignature(body);
+ // for (Iterator it = getAllOperationMetaData().iterator(); it.hasNext();) {
+ // WebServiceOperationMetaData descriptor = (WebServiceOperationMetaData) it.next();
+ //
+ // String style = descriptor.getStyle();
+ //
+ // if (style.equals("document")) {
+ // List s2 = descriptor.getOperationSignature();
+ // if (s1.equals(s2))
+ // return descriptor;
+ // } else {
+ // QName op1 = (QName) s1.get(0);
+ // QName op2 = descriptor.getRPCOperationName();
+ // if (op1.equals(op2)) {
+ // /*
+ // * // FIXME: [rfeng] We don't support method overloading
+ // * List partNames = getOperationSignature(binding,
+ // * bindingOperation); if (rpcParts.equals(partNames))
+ // */
+ // return descriptor;
+ // }
+ // }
+ // }
+ // return null;
+ // }
public List<WebServiceOperationMetaData> getAllOperationMetaData() {
if (allOperationMetaData == null) {
allOperationMetaData = new ArrayList<WebServiceOperationMetaData>();
for (Iterator it = wsdlBinding.getBindingOperations().iterator(); it.hasNext();) {
final BindingOperation bindingOperation = (BindingOperation) it.next();
if (bindingOperation.getOperation() != null) {
- allOperationMetaData.add(new WebServiceOperationMetaData(wsdlBinding,
- bindingOperation));
+ allOperationMetaData.add(new WebServiceOperationMetaData(wsdlBinding, bindingOperation));
}
}
}
@@ -358,6 +366,7 @@
/**
* Returns the WSDL service contract
+ *
* @return
*/
public WSDLServiceContract getInterfaceType() {
@@ -368,7 +377,7 @@
* Get the WSDL operation name for a Java method name
*/
public String getWSDLOperationName(String methodName) {
- StringBuffer sb = new StringBuffer(methodName);
+ StringBuilder sb = new StringBuilder(methodName);
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
String capatalizedOpName = sb.toString();
for (Object o : wsdlPortType.getOperations()) {
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceBindingLoader.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceBindingLoader.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceBindingLoader.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/loader/WebServiceBindingLoader.java Sun Apr 30 01:55:47 2006
@@ -32,7 +32,6 @@
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Scope;
-
/**
* @version $Rev$ $Date$
*/
@@ -60,9 +59,7 @@
}
@SuppressWarnings("deprecation")
- public WebServiceBinding load(XMLStreamReader reader,
- LoaderContext loaderContext)
- throws XMLStreamException, ConfigurationLoadException {
+ public WebServiceBinding load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
WebServiceBinding binding = WS_FACTORY.createWebServiceBinding();
binding.setURI(reader.getAttributeValue(null, "uri"));
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/AxiomHelper.java Sun Apr 30 01:55:47 2006
@@ -48,9 +48,9 @@
* Most of these methods rely on the schemas having been registered with XSDHelper.define
*/
public final class AxiomHelper {
-
+
private AxiomHelper() {
- //utility class, never contructed
+ // utility class, never contructed
}
/**
@@ -107,22 +107,18 @@
try {
ByteArrayOutputStream pos = new java.io.ByteArrayOutputStream();
- new XMLHelperImpl(typeHelper).save(dataObject,
- typeQN.getNamespaceURI(),
- typeQN.getLocalPart(),
- pos);
+ new XMLHelperImpl(typeHelper).save(dataObject, typeQN.getNamespaceURI(), typeQN.getLocalPart(), pos);
pos.close();
XMLStreamReader parser;
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(AxiomHelper.class.getClassLoader());
- parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(pos.toByteArray() ));
+ parser = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(pos.toByteArray()));
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}
- OMXMLParserWrapper builder = OMXMLBuilderFactory
- .createStAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), parser);
OMElement root = builder.getDocumentElement();
return root;
@@ -154,11 +150,11 @@
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}
-
+
pos.flush();
pos.close();
- XMLDocument document = new XMLHelperImpl(typeHelper).load(new ByteArrayInputStream(pos.toByteArray() ));
+ XMLDocument document = new XMLHelperImpl(typeHelper).load(new ByteArrayInputStream(pos.toByteArray()));
return document.getRootObject();
@@ -179,9 +175,7 @@
*/
public static DataObject toDataObject(TypeHelper typeHelper, Object[] os, QName typeQN) {
XSDHelper xsdHelper = new XSDHelperImpl(typeHelper);
- Property property = xsdHelper.getGlobalProperty(typeQN.getNamespaceURI(),
- typeQN.getLocalPart(),
- true);
+ Property property = xsdHelper.getGlobalProperty(typeQN.getNamespaceURI(), typeQN.getLocalPart(), true);
DataObject dataObject = new DataFactoryImpl(typeHelper).create(property.getType());
List ips = dataObject.getInstanceProperties();
for (int i = 0; i < ips.size(); i++) {
@@ -189,5 +183,5 @@
}
return dataObject;
}
-
+
}
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/DataBinding.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/DataBinding.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/DataBinding.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/DataBinding.java Sun Apr 30 01:55:47 2006
@@ -19,8 +19,8 @@
public interface DataBinding {
- Object[] processRequest(OMElement omElement);
+ Object[] fromOMElement(OMElement omElement);
- OMElement processResponse(Object response);
+ OMElement toOMElement(Object[] args);
}
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/SDODataBinding.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/SDODataBinding.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/SDODataBinding.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/SDODataBinding.java Sun Apr 30 01:55:47 2006
@@ -32,13 +32,13 @@
this.typeQN = typeQN;
}
- public Object[] processRequest(OMElement omElement) {
+ public Object[] fromOMElement(OMElement omElement) {
Object[] args = AxiomHelper.toObjects(typeHelper, omElement);
return args;
}
- public OMElement processResponse(Object response) {
- OMElement omElement = AxiomHelper.toOMElement(typeHelper, new Object[] { response }, typeQN);
+ public OMElement toOMElement(Object[] args) {
+ OMElement omElement = AxiomHelper.toOMElement(typeHelper, args, typeQN);
return omElement;
}
Modified: incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java?rev=398299&r1=398298&r2=398299&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/util/TuscanyAxisConfigurator.java Sun Apr 30 01:55:47 2006
@@ -31,9 +31,9 @@
import org.osoa.sca.ServiceRuntimeException;
/**
- * Helps configure Axis2 from a resource in binding.axis2
- * instead of Axis2.xml
- *
+ * Helps configure Axis2 from a resource in binding.axis2 instead of Axis2.xml
+ *
+ * TODO: Review: should there be a single global Axis ConfigurationContext
*/
public class TuscanyAxisConfigurator implements AxisConfigurator {
@@ -42,32 +42,28 @@
protected final ResourceLoader resourceLoader;
/**
- * @param resourceLoader desired resource loader if null use thread context.
- * @param axisConfiguration Starting axis configuration, null then use uninitialized configuration.
+ * @param resourceLoader
+ * desired resource loader if null use thread context.
+ * @param axisConfiguration
+ * Starting axis configuration, null then use uninitialized configuration.
*/
public TuscanyAxisConfigurator(ResourceLoader resourceLoader, AxisConfiguration axisConfiguration) {
- this.resourceLoader = resourceLoader != null ? resourceLoader
- : new ResourceLoaderImpl(getClass().getClassLoader());
- this.axisConfiguration = axisConfiguration == null ? new AxisConfiguration()
- : axisConfiguration;
+ this.resourceLoader = resourceLoader != null ? resourceLoader : new ResourceLoaderImpl(getClass().getClassLoader());
+ this.axisConfiguration = axisConfiguration == null ? new AxisConfiguration() : axisConfiguration;
}
public AxisConfiguration getAxisConfiguration() {
-
+
return axisConfiguration;
}
public ConfigurationContext getConfigurationContext() throws ServiceRuntimeException {
-
-
try {
URL url = resourceLoader.getResource("org/apache/tuscany/binding/axis2/engine/config/axis2.xml");
InputStream serviceInputStream = url.openStream();
- AxisConfigBuilder axisConfigBuilder = new AxisConfigBuilder(serviceInputStream,
- new DeploymentEngine(),
- axisConfiguration);
+ AxisConfigBuilder axisConfigBuilder = new AxisConfigBuilder(serviceInputStream, new DeploymentEngine(), axisConfiguration);
axisConfigBuilder.populateConfig();
serviceInputStream.close();
return ConfigurationContextFactory.createConfigurationContext(this);