You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/07/23 07:56:03 UTC

svn commit: r558614 - in /incubator/tuscany/java/sca: modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/ modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/axis2/engine/config/ samples/simple-callback-w...

Author: rfeng
Date: Sun Jul 22 22:56:01 2007
New Revision: 558614

URL: http://svn.apache.org/viewvc?view=rev&rev=558614
Log:
Apply the 3rd patch from Simon Nash for TUSCANY-1469. Thank you, Simon.

Removed:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2AsyncBindingInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallback.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceCallbackTargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceCallbackTargetInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutAsyncMessageReceiver.java
Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/axis2/engine/config/axis2.xml
    incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java
    incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/simplecallback.composite
    incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl
    incubator/tuscany/java/sca/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2BindingInvoker.java Sun Jul 22 22:56:01 2007
@@ -43,7 +43,8 @@
 import org.osoa.sca.Constants;
 
 /**
- * Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web service
+ * Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web
+ * service
  */
 public class Axis2BindingInvoker implements Invoker {
 
@@ -52,10 +53,12 @@
     private Options options;
     private SOAPFactory soapFactory;
 
-    public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA_NS,"conversationID");
-    
-    public Axis2BindingInvoker(ServiceClient serviceClient, QName wsdlOperationName,
-                               Options options, SOAPFactory soapFactory) {
+    public static final QName CONVERSATION_ID_REFPARM_QN = new QName(Constants.SCA_NS, "conversationID");
+
+    public Axis2BindingInvoker(ServiceClient serviceClient,
+                               QName wsdlOperationName,
+                               Options options,
+                               SOAPFactory soapFactory) {
         this.serviceClient = serviceClient;
         this.wsdlOperationName = wsdlOperationName;
         this.options = options;
@@ -80,21 +83,21 @@
     }
 
     protected Object invokeTarget(final Object payload, final ConversationSequence sequence, String conversationId)
-                             throws InvocationTargetException {
+        throws InvocationTargetException {
         try {
 
-            Object[] args = (Object[]) payload;
+            Object[] args = (Object[])payload;
             OperationClient operationClient = createOperationClient(args, conversationId);
 
             // ensure connections are tracked so that they can be closed by the reference binding
             MessageContext requestMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
             requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
             requestMC.getOptions().setTimeOutInMilliSeconds(120000L);
-                      
+
             operationClient.execute(true);
 
             MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-            
+
             operationClient.complete(requestMC);
 
             return responseMC.getEnvelope().getBody().getFirstElement();
@@ -111,10 +114,10 @@
             SOAPBody body = env.getBody();
             for (Object bc : args) {
                 if (bc instanceof OMElement) {
-                    body.addChild((OMElement) bc);
+                    body.addChild((OMElement)bc);
                 } else {
                     throw new IllegalArgumentException(
-                        "Can't handle mixed payloads betweem OMElements and other types.");
+                                                       "Can't handle mixed payloads betweem OMElements and other types.");
                 }
             }
         }
@@ -133,9 +136,10 @@
             //For now do this the brute force method. Need to figure out how to do axis addressing .. configure mar in flow.
             SOAPEnvelope sev = requestMC.getEnvelope();
             SOAPHeader sh = sev.getHeader();
-            OMElement el = fromEPR.toOM(AddressingConstants.Final.WSA_NAMESPACE,
-                                        AddressingConstants.WSA_FROM,
-                                        AddressingConstants.WSA_DEFAULT_PREFIX);
+            OMElement el =
+                fromEPR.toOM(AddressingConstants.Final.WSA_NAMESPACE,
+                             AddressingConstants.WSA_FROM,
+                             AddressingConstants.WSA_DEFAULT_PREFIX);
             sh.addChild(el);
         }
 
@@ -143,7 +147,6 @@
         if (options.getTo() == null) {
             org.apache.tuscany.sca.runtime.EndpointReference ep = ThreadMessageContext.getMessageContext().getTo();
             if (ep != null) {
-                System.out.println("Axis2BindingInvoker: dynamic endpoint URI is " + ep.getURI());
                 requestMC.setTo(new EndpointReference(ep.getURI()));
             } else {
                 throw new RuntimeException("Unable to determine destination endpoint");
@@ -154,9 +157,10 @@
             //FIXME: is there any way to use the Axis2 addressing support for this?
             SOAPEnvelope sev = requestMC.getEnvelope();
             SOAPHeader sh = sev.getHeader();
-            OMElement el = options.getFrom().toOM(AddressingConstants.Final.WSA_NAMESPACE,
-                                                  AddressingConstants.WSA_FROM,
-                                                  AddressingConstants.WSA_DEFAULT_PREFIX);
+            OMElement el =
+                options.getFrom().toOM(AddressingConstants.Final.WSA_NAMESPACE,
+                                       AddressingConstants.WSA_FROM,
+                                       AddressingConstants.WSA_DEFAULT_PREFIX);
             sh.addChild(el);
         }
         operationClient.addMessageContext(requestMC);

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ReferenceBindingProvider.java Sun Jul 22 22:56:01 2007
@@ -18,38 +18,17 @@
  */
 package org.apache.tuscany.sca.binding.axis2;
 
-import java.util.List;
-
-import javax.wsdl.Binding;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.Definition;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPFactory;
-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.description.AxisService;
-import org.apache.axis2.transport.http.HTTPConstants;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
 import org.apache.tuscany.sca.http.ServletHost;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.InvocationChain;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.MessageFactory;
 import org.apache.tuscany.sca.provider.ReferenceBindingProvider2;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
 
 public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider2 {
 
@@ -62,10 +41,6 @@
     private Axis2ServiceProvider axisProvider;
     private WebServiceBinding callbackBinding;
 
-    //FIXME: following are only needed for the current tactical solutionn
-    private boolean tactical = true;
-    private ServiceClient serviceClient;
-
     public Axis2ReferenceBindingProvider(RuntimeComponent component,
                                          RuntimeComponentReference reference,
                                          WebServiceBinding wsBinding,
@@ -107,8 +82,7 @@
         if (!wsBinding.isCallback()) {
             // this is a forward binding, so look for a matching callback binding
             if (reference.getCallback() != null) {
-                for (org.apache.tuscany.sca.assembly.Binding binding :
-                                          reference.getCallback().getBindings()) {
+                for (Binding binding : reference.getCallback().getBindings()) {
                     if (binding instanceof WebServiceBinding) {
                         // set the first compatible callback binding
                         setCallbackBinding((WebServiceBinding)binding);
@@ -118,32 +92,25 @@
             }
         } else {
             // this is a callback binding, so look for all matching forward bindings
-            for (org.apache.tuscany.sca.assembly.Binding binding : reference.getBindings()) {
+            for (Binding binding : reference.getBindings()) {
                 if (reference.getBindingProvider(binding) instanceof Axis2ReferenceBindingProvider) {
                     // set all compatible forward binding providers for this reference
-                    ((Axis2ReferenceBindingProvider)reference.getBindingProvider(binding)).
-                            setCallbackBinding(wsBinding);
+                    ((Axis2ReferenceBindingProvider)reference.getBindingProvider(binding))
+                        .setCallbackBinding(wsBinding);
                 }
             }
         }
 
-        if (tactical) {
-            if (!wsBinding.isCallback()) {
-                serviceClient = createServiceClient();
-            }
+        if (!wsBinding.isCallback()) {
+            axisClient =
+                new Axis2ServiceClient(component, reference, wsBinding, servletHost, messageFactory, callbackBinding);
         } else {
-            if (!wsBinding.isCallback()) {
-                axisClient = new Axis2ServiceClient(component, reference, wsBinding, servletHost,
-                                                    messageFactory, callbackBinding);
-            } else {
-                //FIXME: need to support callbacks through self-references
-                // For now, don't create a callback service provider for a self-reference
-                // because this modifies the binding URI.  This messes up the service callback
-                // wires because the self-reference has the same binding object as the service.
-                if (!reference.getName().startsWith("$self$.")) {
-                    axisProvider = new Axis2ServiceProvider(component, reference, wsBinding, servletHost,
-                                                            messageFactory);
-                }
+            //FIXME: need to support callbacks through self-references
+            // For now, don't create a callback service provider for a self-reference
+            // because this modifies the binding URI.  This messes up the service callback
+            // wires because the self-reference has the same binding object as the service.
+            if (!reference.getName().startsWith("$self$.")) {
+                axisProvider = new Axis2ServiceProvider(component, reference, wsBinding, servletHost, messageFactory);
             }
         }
     }
@@ -154,78 +121,28 @@
         }
     }
 
-    //FIXME: only needed for the current tactical solution
-    protected ServiceClient createServiceClient() {
-        try {
-            TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
-            ConfigurationContext configContext = tuscanyAxisConfigurator.getConfigurationContext();
-            QName serviceQName = wsBinding.getServiceName();
-            String portName = wsBinding.getPortName();
-            Definition wsdlDefinition = wsBinding.getWSDLDefinition().getDefinition();
-            AxisService axisService = AxisService.createClientSideAxisService(wsdlDefinition,
-                                                                              serviceQName,
-                                                                              portName,
-                                                                              new Options());
-
-            return new ServiceClient(configContext, axisService);
-        } catch (AxisFault e) {
-            throw new RuntimeException(e); // TODO: better exception
-        }
-    }
-
     public void start() {
-        if (tactical) {
-            //FIXME: only needed for the current tactical solution
-            for (InvocationChain chain : reference.getRuntimeWire(wsBinding).getInvocationChains()) {
-                Invoker tailInvoker = chain.getTailInvoker();
-                if (tailInvoker instanceof Axis2AsyncBindingInvoker) {
-                    RuntimeWire callbackWire = reference.getRuntimeWire(callbackBinding);
-                    Operation callbackOperation = findCallbackOperation(callbackBinding.getBindingInterfaceContract());
-                    Axis2CallbackInvocationHandler invocationHandler
-                        = new Axis2CallbackInvocationHandler(messageFactory, callbackWire);
-                    Axis2ReferenceCallbackTargetInvoker callbackInvoker
-                        = new Axis2ReferenceCallbackTargetInvoker(callbackOperation, callbackWire, invocationHandler);
-                    ((Axis2AsyncBindingInvoker)tailInvoker).setCallbackTargetInvoker(callbackInvoker);
-                }
-            }
+        if (!wsBinding.isCallback()) {
+            axisClient.start();
         } else {
-            if (!wsBinding.isCallback()) {
-                axisClient.start();
-            } else {
-                //FIXME: need to support callbacks through self-references
-                if (!reference.getName().startsWith("$self$.")) {
-                    axisProvider.start();
-                }
+            //FIXME: need to support callbacks through self-references
+            if (!reference.getName().startsWith("$self$.")) {
+                axisProvider.start();
             }
         }
     }
 
     public void stop() {
-        if (tactical) {
-            if (!wsBinding.isCallback()) {
-                closeAxis2Connections();
-            }
+        if (!wsBinding.isCallback()) {
+            axisClient.stop();
         } else {
-            if (!wsBinding.isCallback()) {
-                axisClient.stop();
-            } else {
-                //FIXME: need to support callbacks through self-references
-                if (!reference.getName().startsWith("$self$.")) {
-                    axisProvider.stop();
-                }
+            //FIXME: need to support callbacks through self-references
+            if (!reference.getName().startsWith("$self$.")) {
+                axisProvider.stop();
             }
         }
     }
 
-    private void closeAxis2Connections() {
-        // close all connections that we have initiated, so that the jetty server
-        // can be restarted without seeing ConnectExceptions
-        HttpClient httpClient = (HttpClient)serviceClient.getServiceContext().getConfigurationContext()
-            .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
-        if (httpClient != null)
-            ((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown();
-    }
-
     public InterfaceContract getBindingInterfaceContract() {
         return wsBinding.getBindingInterfaceContract();
     }
@@ -247,114 +164,7 @@
         if (wsBinding.isCallback()) {
             throw new RuntimeException("Cannot create invoker for a callback binding");
         }
-        if (!tactical) {
-            return axisClient.createInvoker(operation);
-        }
-
-        //FIXME: remainder of this method's code only needed for the current tactical solution
-        Axis2BindingInvoker invoker;
-
-        if (reference.getInterfaceContract().getCallbackInterface() == null) {
-            invoker = createOperationInvoker(serviceClient, operation, false, operation.isNonBlocking());
-        } else {
-            // FIXME: SDODataBinding needs to pass in TypeHelper and classLoader
-            // as parameters.
-
-            // FIXME: This makes the (BIG) assumption that there is only one
-            // callback method
-            // Relaxing this assumption, however, does not seem to be trivial,
-            // it may depend on knowledge
-            // of what actual callback method was invoked by the service at the
-            // other end
-
-            // the code to create the callback invoker has been moved to the start() method
-
-            Axis2AsyncBindingInvoker asyncInvoker
-                    = (Axis2AsyncBindingInvoker)createOperationInvoker(serviceClient, operation, true, false);
-            invoker = asyncInvoker;
-        }
-
-        return invoker;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    private Operation findCallbackOperation(InterfaceContract contract) {
-        List callbackOperations = contract.getCallbackInterface().getOperations();
-        if (callbackOperations.size() != 1) {
-            throw new RuntimeException("Can only handle one callback operation");
-        }
-        Operation callbackOperation = (Operation)callbackOperations.get(0);
-        return callbackOperation;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    /**
-     * Create and configure an Axis2BindingInvoker for each operation
-     */
-    private Axis2BindingInvoker createOperationInvoker(ServiceClient serviceClient,
-                                                       Operation operation,
-                                                       boolean hasCallback,
-                                                       boolean isOneWay) {
-
-        Options options = new Options();
-        options.setTo(getPortLocationEPR());
-        options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
-
-        String operationName = operation.getName();
-
-        String soapAction = getSOAPAction(operationName);
-        if (soapAction != null && soapAction.length() > 1) {
-            options.setAction(soapAction);
-        }
-
-        options.setTimeOutInMilliSeconds(30 * 1000); // 30 seconds
-
-        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
-        QName wsdlOperationQName = new QName(operationName);
-
-        Axis2BindingInvoker invoker;
-        if (hasCallback) {
-            invoker = new Axis2AsyncBindingInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
-        } else if (isOneWay) {
-            invoker = new Axis2OneWayBindingInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
-        } else {
-            invoker = new Axis2BindingInvoker(serviceClient, wsdlOperationQName, options, soapFactory);
-        }
-
-        return invoker;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    protected EndpointReference getPortLocationEPR() {
-        String ep = wsBinding.getURI();
-        if (ep == null && wsBinding.getPort() != null) {
-            List wsdlPortExtensions = wsBinding.getPort().getExtensibilityElements();
-            for (final Object extension : wsdlPortExtensions) {
-                if (extension instanceof SOAPAddress) {
-                    ep = ((SOAPAddress)extension).getLocationURI();
-                    break;
-                }
-            }
-        }
-        return new EndpointReference(ep);
-    }
-
-    //FIXME: only needed for the current tactical solution
-    protected String getSOAPAction(String operationName) {
-        Binding binding = wsBinding.getBinding();
-        if (binding != null) {
-            for (Object o : binding.getBindingOperations()) {
-                BindingOperation bop = (BindingOperation)o;
-                if (bop.getName().equalsIgnoreCase(operationName)) {
-                    for (Object o2 : bop.getExtensibilityElements()) {
-                        if (o2 instanceof SOAPOperation) {
-                            return ((SOAPOperation)o2).getSoapActionURI();
-                        }
-                    }
-                }
-            }
-        }
-        return null;
+        return axisClient.createInvoker(operation);
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceBindingProvider.java Sun Jul 22 22:56:01 2007
@@ -18,43 +18,12 @@
  */
 package org.apache.tuscany.sca.binding.axis2;
 
-import java.lang.reflect.InvocationTargetException;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Port;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.xml.namespace.QName;
-
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.Constants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.deployment.util.Utils;
-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.wsdl.WSDLConstants;
-import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
-import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
 import org.apache.tuscany.sca.http.ServletHost;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
 import org.apache.tuscany.sca.invocation.MessageFactory;
 import org.apache.tuscany.sca.provider.ServiceBindingProvider2;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -70,13 +39,6 @@
     private Axis2ServiceClient axisClient;
     private Axis2ServiceProvider axisProvider;
 
-    //FIXME: following are only needed for the current tactical solutionn
-    private boolean tactical = true;
-    private ConfigurationContext configContext;
-    private Axis2ServiceBindingProvider callbackProvider;
-    // TODO: what to do about the base URI?
-    private static final String BASE_URI = "http://localhost:8080/";
-
     public Axis2ServiceBindingProvider(RuntimeComponent component,
                                        RuntimeComponentService service,
                                        WebServiceBinding wsBinding,
@@ -89,15 +51,6 @@
         this.servletHost = servletHost;
         this.messageFactory = messageFactory;
 
-        if (tactical) {
-            try {
-                TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
-                configContext = tuscanyAxisConfigurator.getConfigurationContext();
-            } catch (AxisFault e) {
-                throw new RuntimeException(e); // TODO: better exception
-            }
-        }
-
         InterfaceContract contract = wsBinding.getBindingInterfaceContract();
         if (contract == null) {
             contract = service.getInterfaceContract().makeUnidirectional(wsBinding.isCallback());
@@ -112,320 +65,42 @@
             contract.getCallbackInterface().setDefaultDataBinding(OMElement.class.getName());
         }
 
-        //FIXME: only needed for the current tactical solution
-        if (tactical) {
-            // connect forward providers with matching callback providers
-            if (!wsBinding.isCallback()) {
-                // this is a forward binding, so look for a matching callback binding
-                if (service.getCallback() != null) {
-                    for (Binding binding : service.getCallback().getBindings()) {
-                        if (service.getBindingProvider(binding) instanceof Axis2ServiceBindingProvider) {
-                            // use the first compatible callback binding provider for this service
-                            setCallbackProvider((Axis2ServiceBindingProvider)service.getBindingProvider(binding));
-                            continue;
-                        }
-                    }
-                }
-            } else {
-                // this is a callback binding, so look for all matching forward bindings
-                for (Binding binding : service.getBindings()) {
-                    if (service.getBindingProvider(binding) instanceof Axis2ServiceBindingProvider) {
-                        // set all compatible forward binding providers for this service
-                        ((Axis2ServiceBindingProvider)service.getBindingProvider(binding)).setCallbackProvider(this);
-                    }
-                }
-            }
+        if (!wsBinding.isCallback()) {
+            axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost,
+                                                    messageFactory);
         } else {
-            if (!wsBinding.isCallback()) {
-                axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost,
-                                                        messageFactory);
-            } else {
-                // pass null as last parameter because SCDL doesn't allow a callback callback binding
-                // to be specified for a callback binding, i.e., can't have the following:
-                // <service>
-                //   <binding.x/>
-                //   <callback>
-                //     <binding.y/>
-                //     <callback>
-                //       <binding.z/>
-                //     </callback>
-                //   </callback>
-                // </service>
-                // This means that you can't do a callback from a callback (at least not
-                // in s spec-compliant way).
-                axisClient = new Axis2ServiceClient(component, service, wsBinding, servletHost,
-                                                    messageFactory, null);
-            }
-        }
-    }
-
-    //FIXME: only needed for the current tactical solution
-    protected void setCallbackProvider(Axis2ServiceBindingProvider callbackProvider) {
-        if (this.callbackProvider == null) {
-            this.callbackProvider = callbackProvider;
+            // pass null as last parameter because SCDL doesn't allow a callback callback binding
+            // to be specified for a callback binding, i.e., can't have the following:
+            // <service>
+            //   <binding.x/>
+            //   <callback>
+            //     <binding.y/>
+            //     <callback>
+            //       <binding.z/>
+            //     </callback>
+            //   </callback>
+            // </service>
+            // This means that you can't do a callback from a callback (at least not
+            // in s spec-compliant way).
+            axisClient = new Axis2ServiceClient(component, service, wsBinding, servletHost,
+                                                messageFactory, null);
         }
     }
 
     public void start() {
-        if (tactical) {
-            if (!wsBinding.isCallback()) {
-                startAxis2Service();
-            }
+        if (!wsBinding.isCallback()) {
+            axisProvider.start();                                          
         } else {
-            if (!wsBinding.isCallback()) {
-                axisProvider.start();                                          
-            } else {
-                axisClient.start();
-            }
-        }
-    }
-
-    //FIXME: only needed for the current tactical solution
-    private void startAxis2Service() {
-        String uri = computeActualURI(BASE_URI, component, service).normalize().toString();
-        if (uri.endsWith("/")) {
-            uri = uri.substring(0, uri.length() - 1);
+            axisClient.start();
         }
-        wsBinding.setURI(uri.toString());
-
-        // TODO: if <binding.ws> specifies the wsdl service then should create a
-        // service for every port
-
-        try {
-            configContext.getAxisConfiguration().addService(createAxisService());
-        } catch (AxisFault e) {
-            throw new RuntimeException(e);
-        }
-
-        Axis2ServiceServlet servlet = new Axis2ServiceServlet();
-        servlet.init(configContext);
-        String servletURI = wsBinding.getURI();
-        configContext.setContextRoot(servletURI);
-        servletHost.addServletMapping(servletURI, servlet);
     }
 
     public void stop() {
-        if (tactical) {
-            if (!wsBinding.isCallback()) {
-                stopAxis2Service();
-            }
-        } else {
-            if (!wsBinding.isCallback()) {
-                axisProvider.stop();
-            } else {
-                axisClient.stop();
-            }
-        }
-    }
-
-    //FIXME: only needed for the current tactical solution
-    private void stopAxis2Service() {
-        servletHost.removeServletMapping(wsBinding.getURI());
-        try {
-            configContext.getAxisConfiguration().removeService(wsBinding.getURI());
-        } catch (AxisFault e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    //FIXME: only needed for the current tactical solution
-    /**
-     * Compute the endpoint URI based on section 2.1.1 of the WS binding spec 1.
-     * The URIs in the endpoint(s) of the referenced WSDL, which may be relative
-     * 2. The URI specified by the wsa:Address element of the
-     * wsa:EndpointReference, which may be relative 3. The explicitly stated URI
-     * in the "uri" attribute of the binding.ws element, which may be relative,
-     * 4. The implicit URI as defined by in section 1.7 in the SCA Assembly spec
-     * If the <binding.ws> has no wsdlElement but does have a uri attribute then
-     * the uri takes precidence over any implicitly used WSDL.
-     *
-     * @param parent
-     */
-    protected URI computeActualURI(String baseURI, RuntimeComponent component, RuntimeComponentService service) {
-
-        // TODO: support wsa:Address
-
-        URI wsdlURI = null;
-        if (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null) {
-            // <binding.ws> explicitly points at a wsdl port, may be a relative
-            // URI
-            wsdlURI = getEndpoint(wsBinding.getPort());
-        }
-        if (wsdlURI != null && wsdlURI.isAbsolute()) {
-            if (wsBinding.getURI() != null && (wsBinding.getServiceName() != null && wsBinding.getBindingName() == null)) {
-                throw new IllegalArgumentException("binding URI cannot be used with absolute WSDL endpoint URI");
-            }
-            return URI.create(wsdlURI.toString());
-        }
-
-        // either there is no wsdl port endpoint URI or that URI is relative
-
-        URI bindingURI = null;
-        if (wsBinding.getURI() != null) {
-            bindingURI = URI.create(wsBinding.getURI());
-        }
-        if (bindingURI != null && bindingURI.isAbsolute()) {
-            // there is an absoulte uri specified on the binding: <binding.ws
-            // uri="xxx"
-            if (wsdlURI != null) {
-                // there is a relative URI in the wsdl port
-                return URI.create(bindingURI + "/" + wsdlURI);
-            } else {
-                return bindingURI;
-            }
-        }
-
-        // both the WSDL endpoint and binding uri are either unspecified or
-        // relative so
-        // the endpoint is based on the component name and service binding URI
-
-        URI componentURI = URI.create(component.getName());
-
-        String actualURI;
-        if (componentURI.isAbsolute()) {
-            actualURI = componentURI.toString();
-        } else {
-            actualURI = baseURI + "/" + componentURI;
-        }
-
-        // with multiple services the default binding URI is the binding name
-        if (bindingURI == null && component.getServices().size() > 1) {
-            // if the binding doesn't have a name use the name of the service
-            // (assumption, not in spec)
-            if (wsBinding.getName() != null) {
-                bindingURI = URI.create(wsBinding.getName());
-            } else {
-                bindingURI = URI.create(service.getName());
-            }
-        }
-
-        // add any relative binding URI
-        if (bindingURI != null) {
-            actualURI += "/" + bindingURI;
-        }
-
-        // add any relative WSDL port URI
-        if (wsdlURI != null) {
-            actualURI += "/" + wsdlURI.toString();
-        }
-
-        return URI.create(actualURI);
-    }
-
-    //FIXME: only needed for the current tactical solution
-    /**
-     * Returns the endpoint of a given port.
-     */
-    protected URI getEndpoint(Port wsdlPort) {
-        if (wsdlPort != null) {
-            List wsdlPortExtensions = wsdlPort.getExtensibilityElements();
-            for (Object extension : wsdlPortExtensions) {
-                if (extension instanceof SOAPAddress) {
-                    return URI.create(((SOAPAddress)extension).getLocationURI());
-                }
-            }
-        }
-        return null;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    private AxisService createAxisService() throws AxisFault {
-        AxisService axisService;
-        if (wsBinding.getWSDLDefinition() != null) {
-            axisService = createWSDLAxisService();
+        if (!wsBinding.isCallback()) {
+            axisProvider.stop();
         } else {
-            axisService = createJavaAxisService();
+            axisClient.stop();
         }
-        initAxisOperations(axisService);
-        return axisService;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    /**
-     * Create an AxisService from the interface class from the SCA service interface
-     */
-    protected AxisService createJavaAxisService() throws AxisFault {
-        AxisService axisService = new AxisService();
-        String path = URI.create(wsBinding.getURI()).getPath();
-        axisService.setName(path);
-        axisService.setServiceDescription("Tuscany configured AxisService for service: " + wsBinding.getURI());
-        axisService.setClientSide(false);
-        Parameter classParam = new Parameter(Constants.SERVICE_CLASS, ((JavaInterface)service.getInterfaceContract().getInterface()).getJavaClass().getName());
-        axisService.addParameter(classParam);
-        try {
-            Utils.fillAxisService(axisService, configContext.getAxisConfiguration(), null, null);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
-        return axisService;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    /**
-     * Create an AxisService from the WSDL doc used by ws binding
-     */
-    protected AxisService createWSDLAxisService() throws AxisFault {
-        Definition definition = wsBinding.getWSDLDefinition().getDefinition();
-
-        // WSDLToAxisServiceBuilder only uses the service and port to find the wsdl4J Binding
-        // An SCA service with binding.ws does not require a service or port so we may not have
-        // these but ...
-
-        WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(definition, wsBinding.getServiceName(),
-                                                                          wsBinding.getPortName());
-        builder.setServerSide(true);
-        AxisService axisService = builder.populateService();
-
-        String path = URI.create(wsBinding.getURI()).getPath();
-        axisService.setName(path);
-        axisService.setServiceDescription("Tuscany configured AxisService for service: " + wsBinding.getURI());
-
-        // Use the existing WSDL
-        Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null);
-        wsdlParam.setValue(definition);
-        axisService.addParameter(wsdlParam);
-        Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
-        axisService.addParameter(userWSDL);
-
-        return axisService;
-    }
-
-    //FIXME: only needed for the current tactical solution
-    protected void initAxisOperations(AxisService axisService) {
-        for (Iterator i = axisService.getOperations(); i.hasNext();) {
-            AxisOperation axisOp = (AxisOperation)i.next();
-            Operation op = getOperation(axisOp);
-            if (op != null) {
-
-                if (op.isNonBlocking()) {
-                    axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
-                } else {
-                    axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
-                }
-
-                MessageReceiver msgrec = null;
-                if (service.getInterfaceContract().getCallbackInterface() != null) {
-                    msgrec = new Axis2ServiceInOutAsyncMessageReceiver(this, callbackProvider, op);
-                } else if (op.isNonBlocking()) {
-                    msgrec = new Axis2ServiceInMessageReceiver(this, op);
-                } else {
-                    msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op);
-                }
-                axisOp.setMessageReceiver(msgrec);
-            }
-        }
-    }
-    
-    //FIXME: only needed for the current tactical solution
-    protected Operation getOperation(AxisOperation axisOp) {
-        String operationName = axisOp.getName().getLocalPart();
-        for (Operation op : wsBinding.getBindingInterfaceContract().getInterface().getOperations()) {
-            if (op.getName().equalsIgnoreCase(operationName)) {
-                return op;
-            }
-        }
-        return null;
     }
 
     public InterfaceContract getBindingInterfaceContract() {
@@ -436,122 +111,11 @@
         if (!wsBinding.isCallback()) {
             throw new RuntimeException("Cannot create callback invoker for a forward binding");
         }
-        if (tactical) {
-            return new Axis2ServiceCallbackTargetInvoker(this);
-        } else {
-            return axisClient.createInvoker(operation);
-        }
+        return axisClient.createInvoker(operation);
     }
 
     public boolean supportsAsyncOneWayInvocation() {
         return true;
-    }
-
-    //FIXME: remaining code only needed for the current tactical solution
-
-    // methods for Axis2 message receivers
-
-    /**
-     * @param inMC
-     * @return
-     */
-    protected static String getConversationID(MessageContext inMC) {
-        String conversationID = null;
-        Iterator i = inMC.getEnvelope().getHeader()
-            .getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "From"));
-        for (; i.hasNext();) {
-            Object a = i.next();
-            if (a instanceof OMElement) {
-                OMElement ao = (OMElement)a;
-                for (Iterator rpI = ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing",
-                                                                     "ReferenceParameters")); rpI.hasNext();) {
-                    OMElement rpE = (OMElement)rpI.next();
-                    for (Iterator cidI = rpE.getChildrenWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN); cidI
-                        .hasNext();) {
-                        OMElement cidE = (OMElement)cidI.next();
-                        conversationID = cidE.getText();
-                    }
-                }
-
-            }
-
-        }
-        return conversationID;
-    }
-
-    public Object invokeTarget(Operation op, Object[] args, Object messageId, String conversationID)
-        throws InvocationTargetException {
-
-        Message requestMsg = messageFactory.createMessage();
-
-        if (messageId != null) {
-            requestMsg.setMessageID(messageId);
-        }
-        requestMsg.setBody(args);
-
-        //FIXME: need somewhere to store the callback URI 
-        requestMsg.setFrom(service.getRuntimeWire(wsBinding).getSource());
-
-        Message workContext = ThreadMessageContext.getMessageContext();
-
-        ThreadMessageContext.setMessageContext(requestMsg);
-        try {
-            if (isConversational() && conversationID != null) {
-                requestMsg.setConversationID(conversationID);
-            } else {
-                requestMsg.setConversationID(null);
-            }
-
-            Message responseMsg = service.getInvoker(wsBinding, op).invoke(requestMsg);
-
-            if (responseMsg.isFault()) {
-                throw new InvocationTargetException((Throwable)responseMsg.getBody());
-            }
-            return responseMsg.getBody();
-
-        } finally {
-            ThreadMessageContext.setMessageContext(workContext);
-        }
-    }
-
-    public boolean isConversational() {
-        return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
-    }
-
-    // methods for handling callbacks
-
-    private Map<Object, InvocationContext> invCtxMap = new HashMap<Object, InvocationContext>();
-
-    public void addMapping(Object msgId, InvocationContext invCtx) {
-        this.invCtxMap.put(msgId, invCtx);
-    }
-
-    public InvocationContext retrieveMapping(Object msgId) {
-        return this.invCtxMap.get(msgId);
-    }
-
-    public void removeMapping(Object msgId) {
-        this.invCtxMap.remove(msgId);
-    }
-
-    protected class InvocationContext {
-        public MessageContext inMessageContext;
-
-        public Operation operation;
-
-        public SOAPFactory soapFactory;
-
-        public CountDownLatch doneSignal;
-
-        public InvocationContext(MessageContext messageCtx,
-                                 Operation operation,
-                                 SOAPFactory soapFactory,
-                                 CountDownLatch doneSignal) {
-            this.inMessageContext = messageCtx;
-            this.operation = operation;
-            this.soapFactory = soapFactory;
-            this.doneSignal = doneSignal;
-        }
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceClient.java Sun Jul 22 22:56:01 2007
@@ -23,6 +23,8 @@
 import javax.wsdl.Binding;
 import javax.wsdl.BindingOperation;
 import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPOperation;
 import javax.xml.namespace.QName;
@@ -82,15 +84,46 @@
         try {
             TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
             ConfigurationContext configContext = tuscanyAxisConfigurator.getConfigurationContext();
+
+            Definition wsdlDefinition = wsBinding.getWSDLDefinition().getDefinition();
+            setServiceAndPort(wsBinding);
             QName serviceQName = wsBinding.getServiceName();
             String portName = wsBinding.getPortName();
-            Definition wsdlDefinition = wsBinding.getWSDLDefinition().getDefinition();
             AxisService axisService =
                 AxisService.createClientSideAxisService(wsdlDefinition, serviceQName, portName, new Options());
 
             return new ServiceClient(configContext, axisService);
         } catch (AxisFault e) {
             throw new RuntimeException(e); // TODO: better exception
+        }
+    }
+
+    /**
+     * Ensure the WSDL definition contains a suitable service and port
+     */
+    protected static void setServiceAndPort(WebServiceBinding wsBinding) {
+        Definition wsdlDefinition = wsBinding.getWSDLDefinition().getDefinition();
+        QName serviceQName = wsBinding.getServiceName();
+        String portName = wsBinding.getPortName();
+
+        // If no service is specified in the binding element and this is a callback
+        // binding, allow for WSDL that only contains a portType for the callback and
+        // not a service and port.  Synthesize a service and port using WSDL4J and
+        // add them to the wsdlDefinition to keep Axis happy.
+        if (serviceQName == null && wsBinding.isCallback()) {
+            QName bindingQName = wsBinding.getBindingName();
+            Port port = wsdlDefinition.createPort();
+            portName = "$port$." + bindingQName.getLocalPart();
+            port.setName(portName);
+            wsBinding.setPortName(portName);
+            port.setBinding(wsBinding.getBinding());
+            Service service = wsdlDefinition.createService();
+            serviceQName = new QName(bindingQName.getNamespaceURI(),
+                                     "$service$." + bindingQName.getLocalPart());
+            service.setQName(serviceQName);
+            wsBinding.setServiceName(serviceQName);
+            service.addPort(port);
+            wsdlDefinition.addService(service);
         }
     }
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInMessageReceiver.java Sun Jul 22 22:56:01 2007
@@ -37,17 +37,7 @@
         this.operation = operation;
     }
 
-    //FIXME: only needed for the current tactical solution
-    private Axis2ServiceBindingProvider bindingProvider;
-
-    //FIXME: only needed for the current tactical solution
-    public Axis2ServiceInMessageReceiver(Axis2ServiceBindingProvider bindingProvider, Operation operation) {
-        this.bindingProvider = bindingProvider;
-        this.operation = operation;
-    }
-
     public Axis2ServiceInMessageReceiver() {
-
     }
 
     @Override
@@ -55,17 +45,11 @@
         try {
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
-            //FIXME: remove tactical code
-            if (bindingProvider != null) {
-                String conversationID = bindingProvider.isConversational() ?
-                                            Axis2ServiceBindingProvider.getConversationID(inMC) : null;
-                bindingProvider.invokeTarget(operation, args, null, conversationID);
-            } else {
-                String conversationID = provider.isConversational() ?
-                                            Axis2ServiceProvider.getConversationID(inMC) : null;
-                String callbackAddress = provider.getFromEPR(inMC);
-                provider.invokeTarget(operation, args, null, conversationID, callbackAddress);
-            }
+
+            String conversationID = provider.getConversationID(inMC);
+            String callbackAddress = provider.getFromEPR(inMC);
+            provider.invokeTarget(operation, args, null, conversationID, callbackAddress);
+
         } catch (InvocationTargetException e) {
             Throwable t = e.getCause();
             if (t instanceof Exception) {

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java Sun Jul 22 22:56:01 2007
@@ -39,15 +39,6 @@
         this.operation = operation;
     }
 
-    //FIXME: only needed for the current tactical solution
-    private Axis2ServiceBindingProvider bindingProvider;
-
-    //FIXME: only needed for the current tactical solution
-    public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceBindingProvider bindingProvider, Operation operation) {
-        this.bindingProvider = bindingProvider;
-        this.operation = operation;
-    }
-
     public Axis2ServiceInOutSyncMessageReceiver() {
     }
 
@@ -57,19 +48,10 @@
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
             
-            //FIXME: remove tactical code
-            OMElement responseOM = null;
-            if (bindingProvider != null) {
-                String conversationID = bindingProvider.isConversational() ?
-                                            Axis2ServiceBindingProvider.getConversationID(inMC) : null;
-                responseOM = (OMElement)bindingProvider.invokeTarget(operation, args, null, conversationID);
-            } else {
-                String conversationID = provider.isConversational() ?
-                                            Axis2ServiceProvider.getConversationID(inMC) : null;
-                String callbackAddress = provider.getFromEPR(inMC);
-                responseOM = (OMElement)provider.invokeTarget(operation, args, null, conversationID,
-                                                              callbackAddress);
-            }
+            String conversationID = provider.getConversationID(inMC);
+            String callbackAddress = provider.getFromEPR(inMC);
+            OMElement responseOM = (OMElement)provider.invokeTarget(operation, args, null, conversationID,
+                                                                    callbackAddress);
 
             SOAPEnvelope soapEnvelope = getSOAPFactory(inMC).getDefaultEnvelope();
             if(null != responseOM ){
@@ -79,14 +61,12 @@
             outMC.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
 
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
             Throwable t = e.getCause();
             if (t instanceof Exception) {
                 throw AxisFault.makeFault((Exception)t);
             }
             throw new RuntimeException(e);
         } catch (Exception e) {
-            e.printStackTrace();
             throw AxisFault.makeFault(e);
         }
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/axis2/Axis2ServiceProvider.java Sun Jul 22 22:56:01 2007
@@ -21,11 +21,8 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
@@ -33,7 +30,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.ConfigurationContext;
@@ -71,8 +68,11 @@
     private ConfigurationContext configContext;
 
     // TODO: what to do about the base URI?
-    //FIXME: changed from 8080 to 8085 as hack to work around current limitation that base URI
-    // must be the same for all servlet mappings in a single Tomcat or Jetty ServletHost 
+    //FIXME: changed from 8080 to 8085 as a hack to work around current limitation that
+    // the base URI must be the same for all servlet mappings in a single ServletHost.
+    // It appears that the code in both http-tomcat and http-jetty has this restriction.
+    // This port number may be used to construct callback URIs.  The value 8085 is used
+    // beacuse it matches the service port number used by the simple-callback-ws sample.
     private static final String BASE_URI = "http://localhost:8085/";
 
     public Axis2ServiceProvider(RuntimeComponent component,
@@ -116,7 +116,6 @@
         servlet.init(configContext);
         String servletURI = wsBinding.getURI();
         configContext.setContextRoot(servletURI);
-        System.out.println("Axis2ServiceProvider: adding servlet mapping for " + servletURI);
         servletHost.addServletMapping(servletURI, servlet);
     }
 
@@ -190,8 +189,7 @@
 
         // for service bindings with multiple services, the default binding URI is the binding name
         // for callback reference bindings, add a prefix "$callback$." to ensure uniqueness
-        if (bindingURI == null && 
-            (wsBinding.isCallback() || component.getServices().size() > 1)) {
+        if (bindingURI == null && (wsBinding.isCallback() || component.getServices().size() > 1)) {
             if (!wsBinding.isCallback()) {
                 bindingURI = URI.create(wsBinding.getName());
             } else {
@@ -271,8 +269,11 @@
         // An SCA service with binding.ws does not require a service or port so we may not have
         // these but ...
 
-        WSDLToAxisServiceBuilder builder =
-            new WSDL11ToAxisServiceBuilder(definition, wsBinding.getServiceName(), wsBinding.getPortName());
+        Axis2ServiceClient.setServiceAndPort(wsBinding);
+        QName serviceQName = wsBinding.getServiceName();
+        String portName = wsBinding.getPortName();
+
+        WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(definition, serviceQName, portName);
         builder.setServerSide(true);
         AxisService axisService = builder.populateService();
 
@@ -328,58 +329,60 @@
 
     // methods for Axis2 message receivers
 
+    //FIXME: can we use the Axis2 addressing support for this?
     /**
      * @param inMC
      * @return conversationID
      */
-    protected static String getConversationID(MessageContext inMC) {
+    protected String getConversationID(MessageContext inMC) {
         String conversationID = null;
-        Iterator i =
-            inMC.getEnvelope().getHeader()
-                .getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "From"));
-        for (; i.hasNext();) {
-            Object a = i.next();
-            if (a instanceof OMElement) {
-                OMElement ao = (OMElement)a;
-                for (Iterator rpI =
-                    ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "ReferenceParameters")); rpI
-                    .hasNext();) {
-                    OMElement rpE = (OMElement)rpI.next();
-                    for (Iterator cidI = rpE.getChildrenWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN); cidI
-                        .hasNext();) {
-                        OMElement cidE = (OMElement)cidI.next();
-                        conversationID = cidE.getText();
+        if (isConversational()) {
+            SOAPHeader header = inMC.getEnvelope().getHeader();
+            if (header != null) {
+                Iterator i = header.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "From"));
+                for (; i.hasNext();) {
+                    Object a = i.next();
+                    if (a instanceof OMElement) {
+                        OMElement ao = (OMElement)a;
+                        for (Iterator rpI =
+                            ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing",
+                                                             "ReferenceParameters")); rpI.hasNext();) {
+                            OMElement rpE = (OMElement)rpI.next();
+                            for (Iterator cidI =
+                                rpE.getChildrenWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN); cidI.hasNext();) {
+                                OMElement cidE = (OMElement)cidI.next();
+                                conversationID = cidE.getText();
+                            }
+                        }
+
                     }
                 }
-
             }
-
         }
         return conversationID;
     }
 
-    //FIXME: is there any way to use the Axis2 addressing support for this?
-     /**
+    //FIXME: can we use the Axis2 addressing support for this?
+    /**
      * @param inMC
      * @return fromEPR
      */
     protected String getFromEPR(MessageContext inMC) {
         String fromEPR = null;
-        if (contract instanceof RuntimeComponentService &&
-            contract.getInterfaceContract().getCallbackInterface() != null) {
-            //FIXME: this code can get a NPE if WS-Addressing information is not present
-            Iterator i =
-                inMC.getEnvelope().getHeader()
-                    .getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "From"));
-            for (; i.hasNext();) {
-                Object a = i.next();
-                if (a instanceof OMElement) {
-                    OMElement ao = (OMElement)a;
-                    for (Iterator adI =
-                            ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "Address"));
-                            adI.hasNext();) {
-                        OMElement adE = (OMElement)adI.next();
-                        fromEPR = adE.getText();
+        if (contract instanceof RuntimeComponentService && contract.getInterfaceContract().getCallbackInterface() != null) {
+            SOAPHeader header = inMC.getEnvelope().getHeader();
+            if (header != null) {
+                Iterator i = header.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "From"));
+                for (; i.hasNext();) {
+                    Object a = i.next();
+                    if (a instanceof OMElement) {
+                        OMElement ao = (OMElement)a;
+                        for (Iterator adI =
+                            ao.getChildrenWithName(new QName("http://www.w3.org/2005/08/addressing", "Address")); adI
+                            .hasNext();) {
+                            OMElement adE = (OMElement)adI.next();
+                            fromEPR = adE.getText();
+                        }
                     }
                 }
             }
@@ -421,8 +424,9 @@
             Message responseMsg =
                 contract instanceof RuntimeComponentService ? ((RuntimeComponentService)contract).getInvoker(wsBinding,
                                                                                                              op)
-                    .invoke(requestMsg) : ((RuntimeComponentReference)contract).getInvoker(wsBinding, op)
-                    .invoke(requestMsg);
+                    .invoke(requestMsg) : ((RuntimeComponentReference)contract).getCallbackInvocationChain(wsBinding,
+                                                                                                           op)
+                    .getHeadInvoker().invoke(requestMsg);
 
             if (responseMsg.isFault()) {
                 throw new InvocationTargetException((Throwable)responseMsg.getBody());
@@ -435,42 +439,10 @@
     }
 
     public boolean isConversational() {
-        return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
-    }
-
-    // methods for handling callbacks
-
-    private Map<Object, InvocationContext> invCtxMap = new HashMap<Object, InvocationContext>();
-
-    public void addMapping(Object msgId, InvocationContext invCtx) {
-        this.invCtxMap.put(msgId, invCtx);
-    }
-
-    public InvocationContext retrieveMapping(Object msgId) {
-        return this.invCtxMap.get(msgId);
-    }
-
-    public void removeMapping(Object msgId) {
-        this.invCtxMap.remove(msgId);
-    }
-
-    protected class InvocationContext {
-        public MessageContext inMessageContext;
-
-        public Operation operation;
-
-        public SOAPFactory soapFactory;
-
-        public CountDownLatch doneSignal;
-
-        public InvocationContext(MessageContext messageCtx,
-                                 Operation operation,
-                                 SOAPFactory soapFactory,
-                                 CountDownLatch doneSignal) {
-            this.inMessageContext = messageCtx;
-            this.operation = operation;
-            this.soapFactory = soapFactory;
-            this.doneSignal = doneSignal;
+        if (!wsBinding.isCallback()) {
+            return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
+        } else {
+            return wsBinding.getBindingInterfaceContract().getCallbackInterface().isConversational();
         }
     }
 

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/axis2/engine/config/axis2.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/axis2/engine/config/axis2.xml?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/axis2/engine/config/axis2.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/axis2/engine/config/axis2.xml Sun Jul 22 22:56:01 2007
@@ -105,8 +105,6 @@
                          class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
        <!-- Added by Tuscany -->
         <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
-                         class="org.apache.tuscany.sca.binding.axis2.Axis2ServiceInOutAsyncMessageReceiver"/>
-        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
                          class="org.apache.tuscany.sca.binding.axis2.Axis2ServiceInOutSyncMessageReceiver"/>
        <!-- Added by Tuscany -->
         <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
@@ -117,8 +115,6 @@
                          class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
        <!-- Added by Tuscany -->
         <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
-                         class="org.apache.tuscany.sca.binding.axis2.Axis2ServiceInOutAsyncMessageReceiver"/>
-        <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-out"
                          class="org.apache.tuscany.sca.binding.axis2.Axis2ServiceInOutSyncMessageReceiver"/>
     </messageReceivers>
     <!-- ================================================= -->
@@ -408,4 +404,5 @@
         <phase name="MessageOut"/>
     </phaseOrder>
 </axisconfig>
+
 

Modified: incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java (original)
+++ incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java Sun Jul 22 22:56:01 2007
@@ -31,7 +31,7 @@
         
         System.out.println("Main thread " + Thread.currentThread());
         myClient.aClientMethod();
-        Thread.sleep(500);
+        Thread.sleep(1000);
         
         scaDomain.close();
     }

Modified: incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/simplecallback.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/simplecallback.composite?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/simplecallback.composite (original)
+++ incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/simplecallback.composite Sun Jul 22 22:56:01 2007
@@ -28,12 +28,7 @@
                 callbackInterface="simplecallback.MyServiceCallback" />
             <binding.ws wsdlElement="http://simplecallback#wsdl.port(MyServiceSoapService/MyServiceSoapPort)" />
             <callback>
-                <!-- comment out the following for tactical==false -->
                 <binding.ws wsdlElement="http://simplecallback#wsdl.binding(MyServiceCallbackSoapBinding)" />
-                <!-- end of commented out code -->
-                <!-- uncomment the following for tactical==false
-                <binding.ws wsdlElement="http://simplecallback#wsdl.port(MyServiceCallbackSoapService/MyServiceCallbackSoapPort)" />
-                ... end of commented out code -->
             </callback>
         </reference>
         <implementation.java class="simplecallback.MyClientImpl" />
@@ -45,12 +40,7 @@
                 callbackInterface="http://simplecallback#wsdl.interface(MyServiceCallback)" />
             <binding.ws wsdlElement="http://simplecallback#wsdl.port(MyServiceSoapService/MyServiceSoapPort)" />
             <callback>
-                <!-- comment out the following for tactical==false -->
                 <binding.ws wsdlElement="http://simplecallback#wsdl.binding(MyServiceCallbackSoapBinding)" />
-                <!-- end of commented out code -->
-                <!-- uncomment the following for tactical==false
-                <binding.ws wsdlElement="http://simplecallback#wsdl.port(MyServiceCallbackSoapService/MyServiceCallbackSoapPort)" />
-                ... end of commented out code -->
             </callback>
         </service>
         <implementation.java class="simplecallback.MyServiceImpl" />

Modified: incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl (original)
+++ incubator/tuscany/java/sca/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl Sun Jul 22 22:56:01 2007
@@ -31,10 +31,6 @@
                 </complexType>
             </element>
 
-            <element name="someMethodResponse">
-                <complexType/>
-            </element>
-
             <element name="receiveResult">
                 <complexType>
                     <sequence>
@@ -54,10 +50,6 @@
         <wsdl:part element="tns:someMethod" name="parameters"/>
     </wsdl:message>
 
-    <wsdl:message name="someMethodResponse">
-        <wsdl:part element="tns:someMethodResponse" name="parameters"/>
-    </wsdl:message>
-
     <wsdl:message name="receiveResultRequest">
         <wsdl:part element="tns:receiveResult" name="parameters"/>
     </wsdl:message>
@@ -69,9 +61,6 @@
     <wsdl:portType name="MyService">
         <wsdl:operation name="someMethod">
             <wsdl:input message="tns:someMethodRequest" name="someMethodRequest"/>
-            <!-- comment out the following for tactical==false -->
-            <wsdl:output message="tns:someMethodResponse" name="someMethodResponse"/>
-            <!-- end of commented out code -->
         </wsdl:operation>
     </wsdl:portType>
 
@@ -89,11 +78,6 @@
             <wsdl:input name="someMethodRequest">
                 <wsdlsoap:body use="literal"/>
             </wsdl:input>
-            <!-- comment out the following for tactical==false -->
-            <wsdl:output name="someMethodResponse">
-                <wsdlsoap:body use="literal"/>
-            </wsdl:output>
-            <!-- end of commented out code -->
         </wsdl:operation>
     </wsdl:binding>
 
@@ -113,13 +97,6 @@
     <wsdl:service name="MyServiceSoapService">
         <wsdl:port binding="tns:MyServiceSoapBinding" name="MyServiceSoapPort">
             <wsdlsoap:address location="http://localhost:8085/MyServiceComponent"/>
-        </wsdl:port>
-    </wsdl:service>
-
-    <!--FIXME: remove the need for this fake service in the WSDL -->
-    <wsdl:service name="MyServiceCallbackSoapService">
-        <wsdl:port binding="tns:MyServiceCallbackSoapBinding" name="MyServiceCallbackSoapPort">
-            <!-- callback address needs to be determined dynamically -->
         </wsdl:port>
     </wsdl:service>
 

Modified: incubator/tuscany/java/sca/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java?view=diff&rev=558614&r1=558613&r2=558614
==============================================================================
--- incubator/tuscany/java/sca/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java (original)
+++ incubator/tuscany/java/sca/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java Sun Jul 22 22:56:01 2007
@@ -43,8 +43,9 @@
         System.out.println("Main thread " + Thread.currentThread());
         myClient.aClientMethod();
         System.out.println("Sleeping ...");
-        Thread.sleep(300);
+        Thread.sleep(1000);
         assertEquals("-> someMethod -> receiveResult", MyClientImpl.result);
     }
 }
+
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org