tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r529603 - in /incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2: Axis2ReferenceBinding.java Axis2ServiceBinding.java util/WebServiceOperationMetaData.java util/WebServicePortMetaData.java
Date Tue, 17 Apr 2007 13:58:18 GMT
Author: antelder
Date: Tue Apr 17 06:58:17 2007
New Revision: 529603

URL: http://svn.apache.org/viewvc?view=rev&rev=529603
Log:
Fix bugs associated with WS endpoint uri's and associated tidy up

Removed:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServiceOperationMetaData.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/util/WebServicePortMetaData.java
Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java?view=diff&rev=529603&r1=529602&r2=529603
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ReferenceBinding.java
Tue Apr 17 06:58:17 2007
@@ -19,8 +19,13 @@
 package org.apache.tuscany.binding.axis2;
 
 import java.net.URI;
+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;
@@ -33,8 +38,6 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.tuscany.binding.axis2.util.TuscanyAxisConfigurator;
-import org.apache.tuscany.binding.axis2.util.WebServiceOperationMetaData;
-import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
 import org.apache.tuscany.binding.ws.WebServiceBinding;
 import org.apache.tuscany.binding.ws.xml.WebServiceConstants;
 import org.apache.tuscany.interfacedef.Operation;
@@ -49,13 +52,13 @@
 public class Axis2ReferenceBinding extends ReferenceBindingExtension {
 
     private WorkContext workContext;
-    private WebServicePortMetaData wsPortMetaData;
     private ServiceClient serviceClient;
+    private WebServiceBinding wsBinding;
 
     public Axis2ReferenceBinding(URI name, URI targetUri, WebServiceBinding wsBinding) {
         super(name, targetUri);
-        this.wsPortMetaData = new WebServicePortMetaData(wsBinding.getWSDLDefinition().getDefinition(),
wsBinding.getPort(), wsBinding.getURI(), false);
-        this.serviceClient = createServiceClient(wsBinding.getWSDLDefinition().getDefinition(),
wsPortMetaData);
+        this.wsBinding = wsBinding;
+        this.serviceClient = createServiceClient();
     }
 
     public QName getBindingType() {
@@ -72,7 +75,6 @@
             Axis2AsyncTargetInvoker asyncInvoker =
                 (Axis2AsyncTargetInvoker) createOperationInvoker(serviceClient,
                     operation,
-                    wsPortMetaData,
                     true,
                     false);
             // FIXME: This makes the (BIG) assumption that there is only one
@@ -91,7 +93,7 @@
 
             invoker = asyncInvoker;
         } else {
-            invoker = createOperationInvoker(serviceClient, operation, wsPortMetaData, false,
operation.isNonBlocking());
+            invoker = createOperationInvoker(serviceClient, operation, false, operation.isNonBlocking());
         }
         return invoker;
     }
@@ -111,13 +113,14 @@
     /**
      * Create an Axis2 ServiceClient
      */
-    protected ServiceClient createServiceClient(Definition wsdlDefinition, WebServicePortMetaData
wsPortMetaData) {
+    protected ServiceClient createServiceClient() {
         try {
 
             TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
             ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
-            QName serviceQName = wsPortMetaData.getServiceName();
-            String portName = wsPortMetaData.getPortName().getLocalPart();
+            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(configurationContext, axisService);
@@ -131,44 +134,66 @@
      * Create and configure an Axis2TargetInvoker for each operations
      */
     private Axis2TargetInvoker createOperationInvoker(ServiceClient serviceClient,
-                                                      Operation m,
-                                                      WebServicePortMetaData wsPortMetaData,
+                                                      Operation operation,
                                                       boolean hasCallback,
                                                       boolean isOneWay) {
-        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
-        String portTypeNS = wsPortMetaData.getPortTypeName().getNamespaceURI();
-
-        String methodName = m.getName();
-
-        WebServiceOperationMetaData operationMetaData = wsPortMetaData.getOperationMetaData(methodName);
 
         Options options = new Options();
-        options.setTo(new EndpointReference(wsPortMetaData.getEndpoint()));
+        options.setTo(getPortLocationEPR());
         options.setProperty(HTTPConstants.CHUNKED, Boolean.FALSE);
 
-        String wsdlOperationName = operationMetaData.getBindingOperation().getOperation().getName();
+        String operationName = operation.getName();
 
-        String soapAction = wsPortMetaData.getOperationMetaData(wsdlOperationName).getSOAPAction();
+        String soapAction = getSOAPAction(operationName);
         if (soapAction != null && soapAction.length() > 1) {
             options.setAction(soapAction);
         }
 
         options.setTimeOutInMilliSeconds(5 * 60 * 1000);
 
-        QName wsdlOperationQName = new QName(portTypeNS, wsdlOperationName);
+        SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
+        QName wsdlOperationQName = new QName(wsBinding.getNamespace(), operationName);
 
         Axis2TargetInvoker invoker;
         if (hasCallback) {
-            invoker =
-                new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options, soapFactory,
workContext);
+            invoker = new Axis2AsyncTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
         } else if (isOneWay) {
-            invoker =
-                new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
+            invoker = new Axis2OneWayTargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
         } else {
             invoker = new Axis2TargetInvoker(serviceClient, wsdlOperationQName, options,
soapFactory, workContext);
         }
 
         return invoker;
     }
+    
+    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);
+    }
 
+    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;
+    }
 }

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java?view=diff&rev=529603&r1=529602&r2=529603
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
Tue Apr 17 06:58:17 2007
@@ -32,7 +32,6 @@
 import java.util.concurrent.CountDownLatch;
 
 import javax.wsdl.Definition;
-import javax.wsdl.PortType;
 import javax.xml.namespace.QName;
 
 import org.apache.axiom.om.OMElement;
@@ -48,7 +47,6 @@
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
-import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData;
 import org.apache.tuscany.binding.ws.WebServiceBinding;
 import org.apache.tuscany.http.ServletHostExtensionPoint;
 import org.apache.tuscany.interfacedef.InterfaceContract;
@@ -132,13 +130,14 @@
 
     private AxisService createAxisService(WebServiceBinding wsBinding) throws AxisFault {
         Definition definition = wsBinding.getWSDLDefinition().getDefinition();
-        WebServicePortMetaData wsdlPortInfo =
-            new WebServicePortMetaData(definition, wsBinding.getPort(), null, false);
 
-        // TODO investigate if this is 20 wsdl what todo?
-        WSDLToAxisServiceBuilder builder =
-            new WSDL11ToAxisServiceBuilder(definition, wsdlPortInfo.getServiceName(), wsdlPortInfo.getPort()
-                .getName());
+        // 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 
+
+        QName wsdlServiceName = wsBinding.getServiceName();
+        String wsdlPortName = wsBinding.getPortName();
+        WSDLToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(definition, wsdlServiceName,
wsdlPortName );
         builder.setServerSide(true);
         AxisService axisService = builder.populateService();
 
@@ -156,14 +155,10 @@
         Parameter userWSDL = new Parameter("useOriginalwsdl", "true");
         axisService.addParameter(userWSDL);
 
-        PortType wsdlPortType = wsdlPortInfo.getPortType();
-        for (Object o : wsdlPortType.getOperations()) {
-            javax.wsdl.Operation wsdlOperation = (javax.wsdl.Operation) o;
-            String operationName = wsdlOperation.getName();
-
-            Operation op = getOperation(operationName);
+        for (Iterator i = axisService.getOperations(); i.hasNext();) {
+            AxisOperation axisOp = (AxisOperation) i.next();
+            Operation op = getOperation(axisOp);
             if (op != null) {
-                AxisOperation axisOp = axisService.getOperation(new QName(definition.getTargetNamespace(),
operationName));
 
                 if (op.isNonBlocking()) {
                     axisOp.setMessageExchangePattern(WSDL20_2004Constants.MEP_URI_IN_ONLY);
@@ -186,7 +181,8 @@
         return axisService;
     }
 
-    protected Operation getOperation(String operationName) {
+    protected Operation getOperation(AxisOperation axisOp) {
+        String operationName = axisOp.getName().getLocalPart();
         for (Operation op : serviceContract.getInterface().getOperations()) {
            if (op.getName().equalsIgnoreCase(operationName)) {
                return op;
@@ -283,16 +279,8 @@
      * Get the Method from an interface matching the WSDL operation name
      */
     protected Method getMethod(Class<?> serviceInterface, String operationName) throws
BuilderConfigException {
-        // Note: this doesn't support overloaded operations
-        Method[] methods = serviceInterface.getMethods();
-        for (Method m : methods) {
-            if (m.getName().equals(operationName)) {
-                return m;
-            }
-            // tolerate WSDL with capatalized operation name
-            StringBuilder sb = new StringBuilder(operationName);
-            sb.setCharAt(0, Character.toLowerCase(sb.charAt(0)));
-            if (m.getName().equals(sb.toString())) {
+        for (Method m : serviceInterface.getMethods()) {
+            if (m.getName().equalsIgnoreCase(operationName)) {
                 return m;
             }
         }



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


Mime
View raw message