Author: rfeng
Date: Mon Mar  3 10:06:49 2008
New Revision: 633216

URL: http://svn.apache.org/viewvc?rev=633216&view=rev
Log:
Improve the derivation of binding/service/port from portType to get the 
HelloWorldWSDLMergedTestCase running

Added:
    
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java
      - copied, changed from r632045, 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCaseFIXME.java
    
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
   (with props)
    
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
   (with props)
Removed:
    
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCaseFIXME.java
Modified:
    
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
    
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
    
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
    
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
    
incubator/tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java

Modified: 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/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/ws/axis2/Axis2ServiceClient.java?rev=633216&r1=633215&r2=633216&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
 Mon Mar  3 10:06:49 2008
@@ -30,8 +30,10 @@
 import javax.wsdl.Import;
 import javax.wsdl.Port;
 import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
 import javax.xml.namespace.QName;
 import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLInputFactory;
@@ -61,7 +63,9 @@
 import org.apache.tuscany.sca.assembly.AbstractContract;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
 import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
 import org.apache.tuscany.sca.interfacedef.wsdl.xml.XMLDocumentHelper;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -83,13 +87,11 @@
     private static final QName SOAP12_INTENT = new 
QName("http://www.osoa.org/xmlns/sca/1.0";, "soap12");
     private List<PolicyHandler> policyHandlerList = new 
ArrayList<PolicyHandler>();
 
-    
-
     public Axis2ServiceClient(RuntimeComponent component,
                               AbstractContract contract,
                               WebServiceBinding wsBinding,
                               ServletHost servletHost,
-                              MessageFactory messageFactory, 
+                              MessageFactory messageFactory,
                               Map<ClassLoader, List<PolicyHandlerTuple>> 
policyHandlerClassnames) {
 
         this.wsBinding = wsBinding;
@@ -97,14 +99,14 @@
     }
 
     protected void start() {
-        if (serviceClient == null){
+        if (serviceClient == null) {
             this.serviceClient = createServiceClient();
         }
     }
-    
+
     public ServiceClient getServiceClient() {
         return serviceClient;
-    }    
+    }
 
     /**
      * Create an Axis2 ServiceClient
@@ -115,17 +117,18 @@
             ConfigurationContext configContext = 
tuscanyAxisConfigurator.getConfigurationContext();
             createPolicyHandlers();
             setupPolicyHandlers(policyHandlerList, configContext);
-            
+
             Definition wsdlDefinition = 
wsBinding.getWSDLDefinition().getDefinition();
             setServiceAndPort(wsBinding);
-            QName serviceQName = wsBinding.getServiceName();
-            String portName = wsBinding.getPortName();
+            // The service and port can be set by the above call
+            QName serviceQName =
+                wsBinding.getService() != null ? 
wsBinding.getService().getQName() : wsBinding.getServiceName();
+            String portName = wsBinding.getPort() != null ? 
wsBinding.getPort().getName() : wsBinding.getPortName();
             AxisService axisService =
                 createClientSideAxisService(wsdlDefinition, serviceQName, 
portName, new Options());
 
-            HttpClient httpClient = (HttpClient) 
configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT); 
-            if (httpClient == null)
-            {
+            HttpClient httpClient = 
(HttpClient)configContext.getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
+            if (httpClient == null) {
                 MultiThreadedHttpConnectionManager connectionManager = new 
MultiThreadedHttpConnectionManager();
                 HttpConnectionManagerParams connectionManagerParams = new 
HttpConnectionManagerParams();
                 connectionManagerParams.setDefaultMaxConnectionsPerHost(2);
@@ -133,16 +136,14 @@
                 connectionManagerParams.setStaleCheckingEnabled(true);
                 connectionManagerParams.setLinger(0);
                 connectionManager.setParams(connectionManagerParams);
-                httpClient  = new HttpClient(connectionManager);
+                httpClient = new HttpClient(connectionManager);
                 configContext.setThreadPool(new ThreadPool(1, 5));
-                configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
-                                          Boolean.TRUE);
-                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT,
-                                          httpClient);
+                configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, 
Boolean.TRUE);
+                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, 
httpClient);
             }
 
             return new ServiceClient(configContext, axisService);
-           
+
         } catch (AxisFault e) {
             throw new RuntimeException(e); // TODO: better exception
         } catch (ClassNotFoundException e) {
@@ -153,7 +154,7 @@
             throw new RuntimeException(e);
         }
     }
-    
+
     /**
      * URI resolver implementation for xml schema
      */
@@ -178,7 +179,7 @@
             }
         }
     }
-    
+
     /**
      * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205
      * @param definition
@@ -186,11 +187,11 @@
      * @return
      */
     private static Definition getDefinition(Definition definition, QName 
serviceName) {
-        
-        if (serviceName == null){
+
+        if (serviceName == null) {
             return definition;
         }
-        
+
         if (definition == null) {
             return null;
         }
@@ -209,7 +210,7 @@
         }
         return null;
     }
-    
+
     /**
      * This method is copied from AxisService.createClientSideAxisService to
      * work around http://issues.apache.org/jira/browse/WSCOMMONS-228
@@ -227,24 +228,29 @@
                                                           String portName,
                                                           Options options) 
throws AxisFault {
         Definition def = getDefinition(wsdlDefinition, wsdlServiceName);
-        WSDL11ToAxisServiceBuilder serviceBuilder =
-                new WSDL11ToAxisServiceBuilder(def, wsdlServiceName, portName);
+        WSDL11ToAxisServiceBuilder serviceBuilder = new 
WSDL11ToAxisServiceBuilder(def, wsdlServiceName, portName);
         serviceBuilder.setServerSide(false);
         // [rfeng] Add a custom resolver to work around WSCOMMONS-228
         serviceBuilder.setCustomResolver(new URIResolverImpl(def));
         serviceBuilder.setBaseUri(def.getDocumentBaseURI());
         // [rfeng]
         AxisService axisService = serviceBuilder.populateService();
-        AxisEndpoint axisEndpoint = (AxisEndpoint) axisService.getEndpoints()
-                .get(axisService.getEndpointName());
+        AxisEndpoint axisEndpoint = 
(AxisEndpoint)axisService.getEndpoints().get(axisService.getEndpointName());
         options.setTo(new EndpointReference(axisEndpoint.getEndpointURL()));
         if (axisEndpoint != null) {
-            options.setSoapVersionURI((String) axisEndpoint.getBinding()
-                    .getProperty(WSDL2Constants.ATTR_WSOAP_VERSION));
+            
options.setSoapVersionURI((String)axisEndpoint.getBinding().getProperty(WSDL2Constants.ATTR_WSOAP_VERSION));
         }
         return axisService;
     }
 
+    private static <T extends ExtensibilityElement> T 
getExtensibilityElement(List elements, Class<T> type) {
+        for (Object e : elements) {
+            if (type.isInstance(e)) {
+                return type.cast(e);
+            }
+        }
+        return null;
+    }
 
     /**
      * Ensure the WSDL definition contains a suitable service and port
@@ -254,6 +260,10 @@
         QName serviceQName = wsBinding.getServiceName();
         String portName = wsBinding.getPortName();
 
+        if (portName != null || serviceQName != null) {
+            return;
+        }
+
         // If no service is specified in the binding element, allow for WSDL 
that
         // only contains a portType and not a service and port.  Synthesize a
         // service and port using WSDL4J and add them to the wsdlDefinition to
@@ -261,25 +271,26 @@
         //FIXME: it would be better to do this for all WSDLs to explictly 
control the
         // service and port that Axis will use, rather than just hoping the 
user has
         // placed a suitable service and/or port first in the WSDL.
-        if (serviceQName == null && wsBinding.getBinding() != null) {
-            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);
+        WSDLDefinitionHelper helper = new WSDLDefinitionHelper();
+        if (wsBinding.getBinding() == null) {
+            InterfaceContract ic = wsBinding.getBindingInterfaceContract();
+            WSDLInterface wi = (WSDLInterface)ic.getInterface();
+            Service service = helper.createService(wsdlDefinition, 
wi.getPortType());
+            Port port = (Port)service.getPorts().values().iterator().next();
+            wsBinding.setService(service);
+            wsBinding.setPort(port);
+            wsBinding.setBinding(port.getBinding());
+        } else {
+            Service service = helper.createService(wsdlDefinition, 
wsBinding.getBinding());
+            Port port = (Port)service.getPorts().values().iterator().next();
+            wsBinding.setService(service);
+            wsBinding.setPort(port);
         }
+
     }
 
     protected void stop() {
-        if (serviceClient != null){
+        if (serviceClient != null) {
             // close all connections that we have initiated, so that the jetty 
server
             // can be restarted without seeing ConnectExceptions
             HttpClient httpClient =
@@ -287,7 +298,7 @@
                     .getProperty(HTTPConstants.CACHED_HTTP_CLIENT);
             if (httpClient != null)
                 
((MultiThreadedHttpConnectionManager)httpClient.getHttpConnectionManager()).shutdown();
-            
+
             serviceClient = null;
         }
     }
@@ -312,7 +323,8 @@
 
         options.setTimeOutInMilliSeconds(30 * 1000); // 30 seconds
 
-        SOAPFactory soapFactory = requiresSOAP12() ? 
OMAbstractFactory.getSOAP12Factory() : OMAbstractFactory.getSOAP11Factory();
+        SOAPFactory soapFactory =
+            requiresSOAP12() ? OMAbstractFactory.getSOAP12Factory() : 
OMAbstractFactory.getSOAP11Factory();
         QName wsdlOperationQName = new QName(operationName);
 
         Axis2BindingInvoker invoker;
@@ -358,9 +370,14 @@
                     ep = ((SOAPAddress)extension).getLocationURI();
                     break;
                 }
+                if (extension instanceof SOAP12Address) {
+                    SOAP12Address address = (SOAP12Address)extension;
+                    ep = address.getLocationURI();
+                    break;
+                }
             }
         }
-        return ep != null ? new EndpointReference(ep) : null;
+        return ep == null || "".equals(ep) ? null : new EndpointReference(ep);
     }
 
     protected org.apache.axis2.addressing.EndpointReference 
getEPR(WebServiceBinding wsBinding) {
@@ -369,7 +386,8 @@
         }
         try {
 
-            XMLStreamReader parser = 
XMLInputFactory.newInstance().createXMLStreamReader(new 
DOMSource(wsBinding.getEndPointReference()));
+            XMLStreamReader parser =
+                XMLInputFactory.newInstance().createXMLStreamReader(new 
DOMSource(wsBinding.getEndPointReference()));
             StAXOMBuilder builder = new StAXOMBuilder(parser);
             OMElement omElement = builder.getDocumentElement();
             org.apache.axis2.addressing.EndpointReference epr = 
EndpointReferenceHelper.fromOM(omElement);
@@ -400,16 +418,13 @@
         }
         return null;
     }
-    
-    
-    private void createPolicyHandlers() throws IllegalAccessException, 
InstantiationException,
-        ClassNotFoundException {
+
+    private void createPolicyHandlers() throws IllegalAccessException, 
InstantiationException, ClassNotFoundException {
         if (wsBinding instanceof PolicySetAttachPoint) {
             PolicySetAttachPoint policiedBinding = 
(PolicySetAttachPoint)wsBinding;
             PolicyHandler policyHandler = null;
             for (PolicySet policySet : policiedBinding.getPolicySets()) {
-                policyHandler =
-                    PolicyHandlerUtils.findPolicyHandler(policySet, 
policyHandlerClassnames);
+                policyHandler = 
PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames);
                 if (policyHandler != null) {
                     policyHandler.setApplicablePolicySet(policySet);
                     policyHandlerList.add(policyHandler);
@@ -418,8 +433,8 @@
         }
     }
 
-    private void setupPolicyHandlers(List<PolicyHandler> policyHandlers, 
ConfigurationContext configContext)  {
-        for ( PolicyHandler aHandler : policyHandlers ) {
+    private void setupPolicyHandlers(List<PolicyHandler> policyHandlers, 
ConfigurationContext configContext) {
+        for (PolicyHandler aHandler : policyHandlers) {
             aHandler.setUp(configContext);
         }
     }

Modified: 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/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/ws/axis2/Axis2ServiceProvider.java?rev=633216&r1=633215&r2=633216&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
 Mon Mar  3 10:06:49 2008
@@ -81,7 +81,6 @@
 import org.apache.axis2.transport.jms.JMSSender;
 import org.apache.axis2.transport.jms.JMSUtils;
 import org.apache.axis2.wsdl.WSDLConstants;
-import org.apache.neethi.Policy;
 import org.apache.tuscany.sca.assembly.AbstractContract;
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
@@ -409,11 +408,13 @@
             List<?> wsdlPortExtensions = wsdlPort.getExtensibilityElements();
             for (Object extension : wsdlPortExtensions) {
                 if (extension instanceof SOAPAddress) {
-                    return 
URI.create(((SOAPAddress)extension).getLocationURI());
+                    String uri = ((SOAPAddress)extension).getLocationURI();
+                    return (uri == null || "".equals(uri)) ? null : 
URI.create(uri);
                 }
                 if (extension instanceof SOAP12Address) {
                     SOAP12Address address = (SOAP12Address)extension;
-                    return URI.create((address.getLocationURI()));
+                    String uri = address.getLocationURI();
+                    return (uri == null || "".equals(uri)) ? null : 
URI.create(uri);
                 }
             }
         }
@@ -495,8 +496,10 @@
         // these but ...
 
         Axis2ServiceClient.setServiceAndPort(wsBinding);
-        QName serviceQName = wsBinding.getServiceName();
-        String portName = wsBinding.getPortName();
+        // The service and port can be set by the above call
+        QName serviceQName =
+            wsBinding.getService() != null ? wsBinding.getService().getQName() 
: wsBinding.getServiceName();
+        String portName = wsBinding.getPort() != null ? 
wsBinding.getPort().getName() : wsBinding.getPortName();
         
         Definition def = getDefinition(definition, serviceQName);
 

Added: 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java?rev=633216&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java
 Mon Mar  3 10:06:49 2008
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.ws.axis2;
+
+import java.util.Iterator;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingFault;
+import javax.wsdl.BindingInput;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.BindingOutput;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Input;
+import javax.wsdl.Operation;
+import javax.wsdl.Output;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * @version $Rev$ $Date$
+ */
+public class WSDLDefinitionHelper {
+    private static final String SOAP_NS = 
"http://schemas.xmlsoap.org/wsdl/soap/";;
+    private static final QName SOAP_ADDRESS = new QName(SOAP_NS, "address");
+    private static final QName SOAP_BINDING = new QName(SOAP_NS, "binding");
+    private static final QName SOAP_BODY = new QName(SOAP_NS, "body");
+    private static final QName SOAP_OPERATION = new QName(SOAP_NS, 
"operation");
+
+    private static final String BINDING_SUFFIX = "__SOAPBinding";
+    private static final String SERVICE_SUFFIX = "__Service";
+    private static final String PORT_SUFFIX = "__SOAPHTTPPort";
+
+    public Definition cloneDefinition(WSDLFactory factory, Definition 
definition) throws WSDLException {
+        Element root = definition.getDocumentationElement();
+        root = (Element)root.cloneNode(true);
+        WSDLReader reader = factory.newWSDLReader();
+        return reader.readWSDL(definition.getDocumentBaseURI(), root);
+    }
+
+    public Binding createBinding(Definition definition, PortType portType) 
throws WSDLException {
+        Binding binding = definition.createBinding();
+        binding.setPortType(portType);
+        configureBinding(binding, portType);
+        SOAPBinding soapBinding =
+            
(SOAPBinding)definition.getExtensionRegistry().createExtension(Binding.class, 
SOAP_BINDING);
+        soapBinding.setStyle("document");
+        soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http";);
+        binding.addExtensibilityElement(soapBinding);
+
+        createBindingOperations(definition, binding, portType);
+        binding.setUndefined(false);
+        definition.addBinding(binding);
+        return binding;
+    }
+
+    protected void configureBinding(Binding binding, PortType portType) throws 
WSDLException {
+        QName portTypeName = portType.getQName();
+        if (portTypeName != null) {
+            binding.setQName(new QName(portTypeName.getNamespaceURI(), 
portTypeName.getLocalPart() + BINDING_SUFFIX));
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void createBindingOperations(Definition definition, Binding 
binding, PortType portType)
+        throws WSDLException {
+        for (Iterator oi = portType.getOperations().iterator(); oi.hasNext();) 
{
+            Operation operation = (Operation)oi.next();
+            BindingOperation bindingOperation = 
definition.createBindingOperation();
+            bindingOperation.setOperation(operation);
+            configureBindingOperation(bindingOperation, operation);
+            SOAPOperation soapOperation =
+                
(SOAPOperation)definition.getExtensionRegistry().createExtension(BindingOperation.class,
 SOAP_OPERATION);
+            soapOperation.setSoapActionURI("");
+            bindingOperation.addExtensibilityElement(soapOperation);
+            if (operation.getInput() != null) {
+                BindingInput bindingInput = definition.createBindingInput();
+                configureBindingInput(bindingInput, operation.getInput());
+                SOAPBody soapBody =
+                    
(SOAPBody)definition.getExtensionRegistry().createExtension(BindingInput.class, 
SOAP_BODY);
+                soapBody.setUse("literal");
+                bindingInput.addExtensibilityElement(soapBody);
+                bindingOperation.setBindingInput(bindingInput);
+            }
+            if (operation.getOutput() != null) {
+                BindingOutput bindingOutput = definition.createBindingOutput();
+                configureBindingOutput(bindingOutput, operation.getOutput());
+                SOAPBody soapBody =
+                    
(SOAPBody)definition.getExtensionRegistry().createExtension(BindingOutput.class,
 SOAP_BODY);
+                soapBody.setUse("literal");
+                bindingOutput.addExtensibilityElement(soapBody);
+                bindingOperation.setBindingOutput(bindingOutput);
+            }
+            for (Iterator fi = operation.getFaults().values().iterator(); 
fi.hasNext();) {
+                Fault fault = (Fault)fi.next();
+                BindingFault bindingFault = definition.createBindingFault();
+                configureBindingFault(bindingFault, fault);
+                bindingOperation.addBindingFault(bindingFault);
+            }
+            binding.addBindingOperation(bindingOperation);
+        }
+    }
+
+    protected void configureBindingOperation(BindingOperation 
bindingOperation, Operation operation)
+        throws WSDLException {
+        bindingOperation.setName(operation.getName());
+    }
+
+    protected void configureBindingInput(BindingInput bindingInput, Input 
input) throws WSDLException {
+        bindingInput.setName(input.getName());
+    }
+
+    protected void configureBindingOutput(BindingOutput bindingOutput, Output 
output) throws WSDLException {
+        bindingOutput.setName(output.getName());
+    }
+
+    protected void configureBindingFault(BindingFault bindingFault, Fault 
fault) throws WSDLException {
+        bindingFault.setName(fault.getName());
+    }
+
+    public Service createService(Definition definition, PortType portType) {
+        try {
+            Service service = definition.createService();
+            configureService(service, portType);
+            Binding binding = createBinding(definition, portType);
+            createPort(definition, binding, service);
+            definition.addService(service);
+            return service;
+        } catch (WSDLException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    public Service createService(Definition definition, Binding binding) {
+        try {
+            Service service = definition.createService();
+            configureService(service, binding.getPortType());
+            createPort(definition, binding, service);
+            definition.addService(service);
+            return service;
+        } catch (WSDLException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+
+    protected void configureService(Service service, PortType portType) throws 
WSDLException {
+        QName portTypeName = portType.getQName();
+        if (portTypeName != null) {
+            service.setQName(new QName(portTypeName.getNamespaceURI(), 
portTypeName.getLocalPart() + SERVICE_SUFFIX));
+        }
+    }
+
+    protected Port createPort(Definition definition, Binding binding, Service 
service) throws WSDLException {
+        Port port = definition.createPort();
+        port.setBinding(binding);
+        configurePort(definition, port, binding);
+        /*
+        ExtensibilityElement soapAddress =
+            definition.getExtensionRegistry().createExtension(Port.class, 
SOAP_ADDRESS);
+        ((SOAPAddress)soapAddress).setLocationURI("");
+        port.addExtensibilityElement(soapAddress);
+        */
+        service.addPort(port);
+        return port;
+    }
+
+    protected void configurePort(Definition definition, Port port, Binding 
binding) throws WSDLException {
+        if (binding.getPortType() != null && binding.getPortType().getQName() 
!= null) {
+            port.setName(binding.getPortType().getQName().getLocalPart() + 
PORT_SUFFIX);
+        }
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/WSDLDefinitionHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java
 (from r632045, 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCaseFIXME.java)
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java?p2=incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java&p1=incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCaseFIXME.java&r1=632045&r2=633216&rev=633216&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCaseFIXME.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java
 Mon Mar  3 10:06:49 2008
@@ -28,7 +28,7 @@
 import org.apache.axiom.om.OMText;
 import org.apache.tuscany.sca.host.embedded.SCADomain;
 
-public class HelloWorldWSDLMergedTestCaseFIXME extends TestCase {
+public class HelloWorldWSDLMergedTestCase extends TestCase {
 
     private SCADomain domain;
     private HelloWorldOM helloWorld;

Modified: 
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java?rev=633216&r1=633215&r2=633216&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
 Mon Mar  3 10:06:49 2008
@@ -52,10 +52,8 @@
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
 import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
 import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
 
 public class WebServiceBindingProcessor implements
     StAXArtifactProcessor<WebServiceBinding>, WebServiceConstants {
@@ -305,19 +303,19 @@
 
     private PortType getPortType(WebServiceBinding model) {
         PortType portType = null;
-        if (model.getService() != null) {
+        if (model.getPort() != null) {
+            portType = model.getPort().getBinding().getPortType();
+        } else if (model.getEndpoint() != null) {
+            portType = model.getPort().getBinding().getPortType();
+        } else if (model.getBinding() != null) {
+            portType = model.getBinding().getPortType();
+        } else if (model.getService() != null) {
             // FIXME: How to find the compatible port?
             Map ports = model.getService().getPorts();
             if (!ports.isEmpty()) {
                 Port port = (Port)ports.values().iterator().next();
                 portType = port.getBinding().getPortType();
             }
-        } else if (model.getPort() != null) {
-            portType = model.getPort().getBinding().getPortType();
-        } else if (model.getEndpoint() != null) {
-            portType = model.getPort().getBinding().getPortType();
-        } else if (model.getBinding() != null) {
-            portType = model.getBinding().getPortType();
         }
         return portType;
     }

Added: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java?rev=633216&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
 Mon Mar  3 10:06:49 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.interfacedef.wsdl;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * WSDL 1.1 Operation
+ * @version $Rev$ $Date$
+ */
+public interface WSDLOperation extends Operation {
+    /**
+     * Get the underlying WSDL operation
+     * @return
+     */
+    javax.wsdl.Operation getWsdlOperation();
+    
+    /**
+     * Set the underlying WSDL operation
+     * @param operation
+     */
+    void setWsdlOperation(javax.wsdl.Operation operation);
+}

Propchange: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java?rev=633216&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
 Mon Mar  3 10:06:49 2008
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.interfacedef.wsdl.impl;
+
+import javax.wsdl.Operation;
+
+import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WSDLOperationImpl extends OperationImpl implements WSDLOperation {
+    private Operation operation;
+
+    public WSDLOperationImpl() {
+        super();
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation#getWsdlOperation()
+     */
+    public Operation getWsdlOperation() {
+        return operation;
+    }
+
+    /**
+     * @see 
org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation#setWsdlOperation(javax.wsdl.Operation)
+     */
+    public void setWsdlOperation(Operation operation) {
+        this.operation = operation;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((operation == null) ? 0 : 
operation.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (!super.equals(obj))
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        final WSDLOperationImpl other = (WSDLOperationImpl)obj;
+        if (operation == null) {
+            if (other.operation != null)
+                return false;
+        } else if (!operation.equals(other.operation))
+            return false;
+        return true;
+    }
+
+    public String toString() {
+        return operation == null ? null : operation.toString();
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java?rev=633216&r1=633215&r2=633216&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
 Mon Mar  3 10:06:49 2008
@@ -39,7 +39,6 @@
 import org.apache.tuscany.sca.interfacedef.DataType;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
 import org.apache.tuscany.sca.interfacedef.util.ElementInfo;
 import org.apache.tuscany.sca.interfacedef.util.FaultException;
 import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
@@ -47,6 +46,7 @@
 import org.apache.tuscany.sca.interfacedef.util.XMLType;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
 import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLOperation;
 import org.apache.tuscany.sca.interfacedef.wsdl.XSDefinition;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
 import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -70,7 +70,7 @@
     private ModelResolver resolver;
     private WSDLDefinition wsdlDefinition;
     private javax.wsdl.Operation operation;
-    private Operation operationModel;
+    private WSDLOperation operationModel;
     private DataType<List<DataType>> inputType;
     private DataType outputType;
     private List<DataType> faultTypes;
@@ -108,9 +108,10 @@
     public boolean isWrapperStyle() throws InvalidWSDLException {
         if (wrapperStyle == null) {
             wrapperStyle =
-                (operation.getInput() == null || 
operation.getInput().getMessage().getParts().size() == 0 || wrapper
-                    .getInputChildElements() != null) && 
(operation.getOutput() == null || operation.getOutput()
-                    .getMessage().getParts().size() == 0 || 
wrapper.getOutputChildElements() != null);
+                (operation.getInput() == null || 
operation.getInput().getMessage() == null
+                    || operation.getInput().getMessage().getParts().size() == 
0 || wrapper.getInputChildElements() != null) && (operation
+                    .getOutput() == null || operation.getOutput().getMessage() 
== null
+                    || operation.getOutput().getMessage().getParts().size() == 
0 || wrapper.getOutputChildElements() != null);
         }
         return wrapperStyle;
     }
@@ -207,7 +208,8 @@
     public Operation getOperation() throws InvalidWSDLException {
         if (operationModel == null) {
             boolean oneway = (operation.getOutput() == null);
-            operationModel = new OperationImpl();
+            operationModel = new WSDLOperationImpl();
+            operationModel.setWsdlOperation(operation);
             operationModel.setName(operation.getName());
             operationModel.setFaultTypes(getFaultTypes());
             operationModel.setNonBlocking(oneway);

Modified: 
incubator/tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java?rev=633216&r1=633215&r2=633216&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java
 (original)
+++ 
incubator/tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/TuscanyWSDLTypesGenerator.java
 Mon Mar  3 10:06:49 2008
@@ -264,7 +264,7 @@
 
         XmlSchemaElement globalElement = new XmlSchemaElement();
         globalElement.setSchemaType(complexType);
-        globalElement.setName(formGlobalElementName(localPartName));
+        globalElement.setName(localPartName);
         globalElement.setQName(elementName);
 
         xmlSchema.getItems().add(globalElement);
@@ -275,11 +275,6 @@
                                        elementName);
 
         return complexType;
-    }
-
-    private String formGlobalElementName(String typeName) {
-        String firstChar = typeName.substring(0, 1);
-        return typeName.replaceFirst(firstChar, firstChar.toLowerCase());
     }
 
     public TuscanyTypeTable getTypeTable() {



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to