tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r652445 - in /incubator/tuscany/java/sca/modules: binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/ interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/ interface-wsdl-java2ws...
Date Thu, 01 May 2008 07:42:01 GMT
Author: nash
Date: Thu May  1 00:42:00 2008
New Revision: 652445

URL: http://svn.apache.org/viewvc?rev=652445&view=rev
Log:
Fix problems in new Java2WSDL generation code

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/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/java2wsdl/Java2WSDLHelper.java
    incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.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=652445&r1=652444&r2=652445&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
Thu May  1 00:42:00 2008
@@ -34,6 +34,7 @@
 import javax.wsdl.Definition;
 import javax.wsdl.Import;
 import javax.wsdl.Port;
+import javax.wsdl.PortType;
 import javax.wsdl.Service;
 import javax.wsdl.extensions.ExtensibilityElement;
 import javax.wsdl.extensions.soap.SOAPAddress;
@@ -72,6 +73,7 @@
 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.interface2wsdl.WSDLDefinitionGenerator;
 import org.apache.tuscany.sca.interfacedef.wsdl.xml.XMLDocumentHelper;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.MessageFactory;
@@ -302,19 +304,19 @@
             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
-        // keep Axis happy.
-        //FIXME: it would be better to do this for all WSDLs to explicitly 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.
-        WSDLDefinitionHelper helper = new WSDLDefinitionHelper();
+        // If no WSDL service or port is specified in the binding element, add a
+        // suitably configured service and port to the WSDL definition.  
+        WSDLDefinitionGenerator helper =
+                new WSDLDefinitionGenerator(Axis2ServiceBindingProvider.requiresSOAP12(wsBinding));
         if (wsBinding.getBinding() == null) {
             InterfaceContract ic = wsBinding.getBindingInterfaceContract();
             WSDLInterface wi = (WSDLInterface)ic.getInterface();
-            Service service = helper.createService(wsdlDefinition, wi.getPortType());
-            Binding binding = helper.createBinding(wsdlDefinition, wi.getPortType());
+            PortType portType = wi.getPortType();
+            Service service = helper.createService(wsdlDefinition, portType);
+            Binding binding = helper.createBinding(wsdlDefinition, portType);
+            helper.createBindingOperations(wsdlDefinition, binding, portType);
+            binding.setUndefined(false);
+            wsdlDefinition.addBinding(binding);
             
             Port port = helper.createPort(wsdlDefinition, binding, service, wsBinding.getURI());
             wsBinding.setService(service);

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java?rev=652445&r1=652444&r2=652445&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Interface2WSDLGenerator.java
Thu May  1 00:42:00 2008
@@ -84,15 +84,22 @@
 
     private WSDLFactory factory;
     private DataBindingExtensionPoint dataBindingExtensionPoint;
-    private WSDLDefinitionGenerator definitionGenerator = new WSDLDefinitionGenerator();
+    private WSDLDefinitionGenerator definitionGenerator;
+    private boolean requiresSOAP12; 
 
-    public Interface2WSDLGenerator() throws WSDLException {
+    public Interface2WSDLGenerator(boolean requiresSOAP12) throws WSDLException {
         super();
+        this.requiresSOAP12 = requiresSOAP12; 
+        definitionGenerator = new WSDLDefinitionGenerator(requiresSOAP12);
         this.factory = WSDLFactory.newInstance();
     }
 
-    public Interface2WSDLGenerator(WSDLFactory factory, DataBindingExtensionPoint dataBindingExtensionPoint)
{
+    public Interface2WSDLGenerator(boolean requiresSOAP12,
+                                   WSDLFactory factory,
+                                   DataBindingExtensionPoint dataBindingExtensionPoint) {
         super();
+        this.requiresSOAP12 = requiresSOAP12; 
+        definitionGenerator = new WSDLDefinitionGenerator(requiresSOAP12);
         this.factory = factory;
         this.dataBindingExtensionPoint = dataBindingExtensionPoint;
     }
@@ -109,13 +116,18 @@
         }
         QName name = getQName(interfaze);
         Definition definition = factory.newDefinition();
-        definition.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+        if (requiresSOAP12) {
+            definition.addNamespace("soap12", "http://schemas.xmlsoap.org/wsdl/soap12/");
+        } else {
+            definition.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
+        }
         definition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
         definition.addNamespace("xs", SCHEMA_NS);
 
-        definition.setTargetNamespace(name.getNamespaceURI());
-        definition.setQName(name);
-        definition.addNamespace(name.getPrefix(), name.getNamespaceURI());
+        String namespaceURI = name.getNamespaceURI();
+        definition.setTargetNamespace(namespaceURI);
+        definition.setQName(new QName(namespaceURI, name.getLocalPart() + "Service", name.getPrefix()));
+        definition.addNamespace(name.getPrefix(), namespaceURI);
 
         PortType portType = definition.createPortType();
         portType.setQName(name);
@@ -280,7 +292,7 @@
         Input input = definition.createInput();
         input.setName("input");
         Message inputMsg = definition.createMessage();
-        QName inputMsgName = new QName(definition.getQName().getNamespaceURI(), op.getName()
+ "_InputMessage");
+        QName inputMsgName = new QName(definition.getQName().getNamespaceURI(), op.getName());
         inputMsg.setQName(inputMsgName);
         inputMsg.setUndefined(false);
         definition.addMessage(inputMsg);
@@ -304,7 +316,7 @@
             Output output = definition.createOutput();
             output.setName("output");
             Message outputMsg = definition.createMessage();
-            QName outputMsgName = new QName(definition.getQName().getNamespaceURI(), op.getName()
+ "_OutputMessage");
+            QName outputMsgName = new QName(definition.getQName().getNamespaceURI(), op.getName()
+ "Response");
             outputMsg.setQName(outputMsgName);
             outputMsg.setUndefined(false);
             definition.addMessage(outputMsg);

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java?rev=652445&r1=652444&r2=652445&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/WSDLDefinitionGenerator.java
Thu May  1 00:42:00 2008
@@ -36,9 +36,15 @@
 import javax.wsdl.Service;
 import javax.wsdl.Types;
 import javax.wsdl.WSDLException;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPBody;
 import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
+import javax.wsdl.extensions.soap12.SOAP12Body;
+import javax.wsdl.extensions.soap12.SOAP12Operation;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
@@ -55,10 +61,30 @@
     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";
+    private static final String SOAP12_NS = "http://schemas.xmlsoap.org/wsdl/soap12/";
+    private static final QName SOAP12_ADDRESS = new QName(SOAP12_NS, "address");
+    private static final QName SOAP12_BINDING = new QName(SOAP12_NS, "binding");
+    private static final QName SOAP12_BODY = new QName(SOAP12_NS, "body");
+    private static final QName SOAP12_OPERATION = new QName(SOAP12_NS, "operation");
+
+    private static final String BINDING_SUFFIX = "Binding";
+    private static final String SERVICE_SUFFIX = "Service";
+    private static final String PORT_SUFFIX = "Port";
+
+    private boolean requiresSOAP12;
+    private QName soapAddress;
+    private QName soapBinding;
+    private QName soapBody;
+    private QName soapOperation;
+
+    public WSDLDefinitionGenerator(boolean requiresSOAP12) {
+        super();
+        this.requiresSOAP12 = requiresSOAP12;
+        soapAddress = requiresSOAP12 ? SOAP12_ADDRESS : SOAP_ADDRESS;
+        soapBinding = requiresSOAP12 ? SOAP12_BINDING : SOAP_BINDING;
+        soapBody = requiresSOAP12 ? SOAP12_BODY : SOAP_BODY;
+        soapOperation = requiresSOAP12 ? SOAP12_OPERATION : SOAP_OPERATION;
+    }
 
     public Definition cloneDefinition(WSDLFactory factory, Definition definition) throws
WSDLException {
         Element root = definition.getDocumentationElement();
@@ -73,22 +99,52 @@
         return types;
     }
 
-    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);
-        return binding;
+    public Binding createBinding(Definition definition, PortType portType) {
+        try {
+            Binding binding = definition.createBinding();
+            binding.setPortType(portType);
+            configureBinding(definition, binding, portType);
+            ExtensibilityElement bindingExtension =
+                definition.getExtensionRegistry().createExtension(Binding.class, soapBinding);
+            if (requiresSOAP12) {
+                ((SOAP12Binding)bindingExtension).setStyle("document");
+                ((SOAP12Binding)bindingExtension).setTransportURI("http://schemas.xmlsoap.org/soap/http");
+            } else {
+                ((SOAPBinding)bindingExtension).setStyle("document");
+                ((SOAPBinding)bindingExtension).setTransportURI("http://schemas.xmlsoap.org/soap/http");
+            }
+            binding.addExtensibilityElement(bindingExtension);
+            return binding;
+        } catch (WSDLException e) {
+            throw new IllegalArgumentException(e);
+        }
     }
 
-    protected void configureBinding(Binding binding, PortType portType) throws WSDLException
{
+    protected void configureBinding(Definition definition, Binding binding, PortType portType)
throws WSDLException {
         QName portTypeName = portType.getQName();
         if (portTypeName != null) {
-            binding.setQName(new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart()
+ BINDING_SUFFIX));
+            // Choose <porttype>Binding if available.  If this name is in use, insert
+            // separating underscores until there is no clash.
+            for (String suffix = BINDING_SUFFIX; ; suffix = "_" + suffix) { 
+                QName name = new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart()
+ suffix);
+                if (definition.getBinding(name) == null) {
+                    binding.setQName(name);
+                    break;
+                }
+            }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public void createBindingOperations(Definition definition, Binding binding, PortType
portType) {
+        try {
+            for (Iterator oi = portType.getOperations().iterator(); oi.hasNext();) {
+                Operation operation = (Operation)oi.next();
+                BindingOperation bindingOperation = createBindingOperation(definition, operation,
"");
+                binding.addBindingOperation(bindingOperation);
+            }
+        } catch (WSDLException e) {
+            throw new IllegalArgumentException(e);
         }
     }
 
@@ -98,26 +154,38 @@
         BindingOperation bindingOperation = definition.createBindingOperation();
         bindingOperation.setOperation(operation);
         configureBindingOperation(bindingOperation, operation);
-        SOAPOperation soapOperation =
-            (SOAPOperation)definition.getExtensionRegistry().createExtension(BindingOperation.class,
SOAP_OPERATION);
-        soapOperation.setSoapActionURI(action);
-        bindingOperation.addExtensibilityElement(soapOperation);
+        ExtensibilityElement operationExtension =
+            definition.getExtensionRegistry().createExtension(BindingOperation.class, soapOperation);
+        if (requiresSOAP12) {
+            ((SOAP12Operation)operationExtension).setSoapActionURI(action);
+        } else {
+            ((SOAPOperation)operationExtension).setSoapActionURI(action);
+        }
+        bindingOperation.addExtensibilityElement(operationExtension);
         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);
+            ExtensibilityElement inputExtension =
+                definition.getExtensionRegistry().createExtension(BindingInput.class, soapBody);
+            if (requiresSOAP12) {
+                ((SOAP12Body)inputExtension).setUse("literal");
+            } else {
+                ((SOAPBody)inputExtension).setUse("literal");
+            }
+            bindingInput.addExtensibilityElement(inputExtension);
             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);
+            ExtensibilityElement outputExtension =
+                definition.getExtensionRegistry().createExtension(BindingOutput.class, soapBody);
+            if (requiresSOAP12) {
+                ((SOAP12Body)outputExtension).setUse("literal");
+            } else {
+                ((SOAPBody)outputExtension).setUse("literal");
+            }
+            bindingOutput.addExtensibilityElement(outputExtension);
             bindingOperation.setBindingOutput(bindingOutput);
         }
         for (Iterator fi = operation.getFaults().values().iterator(); fi.hasNext();) {
@@ -149,9 +217,8 @@
     public Service createService(Definition definition, PortType portType) {
         try {
             Service service = definition.createService();
-            configureService(service, portType);
-            Binding binding = createBinding(definition, portType);
-            createPort(definition, binding, service);
+            configureService(definition, service, portType);
+            // createPort(definition, binding, service);
             definition.addService(service);
             return service;
         } catch (WSDLException e) {
@@ -162,8 +229,8 @@
     public Service createService(Definition definition, Binding binding) {
         try {
             Service service = definition.createService();
-            configureService(service, binding.getPortType());
-            createPort(definition, binding, service);
+            configureService(definition, service, binding.getPortType());
+            // createPort(definition, binding, service);
             definition.addService(service);
             return service;
         } catch (WSDLException e) {
@@ -171,28 +238,44 @@
         }
     }
 
-    protected void configureService(Service service, PortType portType) throws WSDLException
{
+    protected void configureService(Definition definition, Service service, PortType portType)
throws WSDLException {
         QName portTypeName = portType.getQName();
         if (portTypeName != null) {
-            service.setQName(new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart()
+ SERVICE_SUFFIX));
+            // Choose <porttype>Service if available.  If this name is in use, insert
+            // separating underscores until there is no clash.
+            for (String suffix = SERVICE_SUFFIX; ; suffix = "_" + suffix) {
+                QName name = new QName(portTypeName.getNamespaceURI(), portTypeName.getLocalPart()
+ suffix);
+                if (definition.getService(name) == null) {
+                    service.setQName(name);
+                     break;
+                }
+            }
         }
     }
 
-    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;
+    public Port createPort(Definition definition, Binding binding, Service service, String
uri) {
+        try {
+            Port port = definition.createPort();
+            port.setBinding(binding);
+            configurePort(port, binding);
+            if (uri != null) {
+                ExtensibilityElement portExtension =
+                    definition.getExtensionRegistry().createExtension(Port.class, soapAddress);
+                if (requiresSOAP12) {
+                    ((SOAP12Address)portExtension).setLocationURI(uri);
+                } else {
+                    ((SOAPAddress)portExtension).setLocationURI(uri);
+                }
+                port.addExtensibilityElement(portExtension);
+            }
+            service.addPort(port);
+            return port;
+        } catch (WSDLException e) {
+            throw new IllegalArgumentException(e);
+        }
     }
 
-    protected void configurePort(Definition definition, Port port, Binding binding) throws
WSDLException {
+    protected void configurePort(Port port, Binding binding) throws WSDLException {
         if (binding.getPortType() != null && binding.getPortType().getQName() !=
null) {
             port.setName(binding.getPortType().getQName().getLocalPart() + PORT_SUFFIX);
         }

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/java2wsdl/Java2WSDLHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/java2wsdl/Java2WSDLHelper.java?rev=652445&r1=652444&r2=652445&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/java2wsdl/Java2WSDLHelper.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/java2wsdl/Java2WSDLHelper.java
Thu May  1 00:42:00 2008
@@ -86,6 +86,10 @@
  * Utility methods to create WSDL objects from Java interfaces
  */
 public class Java2WSDLHelper {
+    // the following 3 switches are temporary for debugging
+    public static boolean newGenerator;  // external code sets this to force new generator
+    public static boolean oldGenerator;  // external code sets this to force old generator
+    public static boolean printWSDL;     // external code sets this to print generated WSDL
 
     private static void register(Map<String, String> map, DataType type) {
         if (type == null) {
@@ -104,6 +108,44 @@
         }
     }
 
+    //FIXME: temp code to control whether the old or new path is used.
+    // Will be removed when the new path can handle all cases.
+    private static boolean useNewGenerator(JavaInterface iface) {
+        /* restore the following code when the new generator supports exception mapping 
+        // check databindings to see if new generator can be used
+        boolean newGenerator = true;
+        for (Operation op : iface.getOperations()) {
+            DataType<List<DataType>> inputType = op.getInputType();
+            for (DataType t : inputType.getLogical()) {
+                newGenerator &= checkDataBinding(t);
+            }
+            DataType outputType = op.getOutputType();
+            newGenerator &= checkDataBinding(outputType);
+        }
+        return newGenerator;
+        */
+        return iface.getQName() != null;  // use new generator for @WebService 
+    }
+
+    /*
+    //FIXME: temp code to control whether the old or new path is used.
+    // Will be removed when the new path can handle all databindings.
+    private static boolean checkDataBinding(DataType dt) {
+        boolean result = (dt == null ||
+               "java:simpleType".equals(dt.getDataBinding()) ||
+               "java:complexType".equals(dt.getDataBinding()) ||
+               "java:array".equals(dt.getDataBinding()) ||
+               "java.io.Externalizable".equals(dt.getDataBinding()) ||
+               "org.osoa.sca.CallableReference".equals(dt.getDataBinding()) ||
+               "org.apache.axiom.om.OMElement".equals(dt.getDataBinding()) ||
+               "javax.xml.bind.JAXBElement".equals(dt.getDataBinding()));
+        if (!result) {
+            System.out.println("$$ unsupported databinding " + dt.getDataBinding());
+        }
+        return result;
+    }
+    */
+
     /**
      * Create a WSDLInterfaceContract from a JavaInterfaceContract
      */
@@ -124,11 +166,25 @@
 
         final WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
         JavaInterface iface = (JavaInterface)contract.getInterface();
-        
-        //FIXME: When Interface2WSDLGenerator is fully working, change this code
-        // to use it in all cases instead of calling createDefinition()
+
+        //FIXME: When Interface2WSDLGenerator supports all databindings, change this
+        // code to use it in all cases instead of calling createDefinition()
         Definition def = null;
-        if (iface.getQName() == null) {  // plain Java interface 
+        if (newGenerator || (!oldGenerator && useNewGenerator(iface))) {
+            /*
+            System.out.println("$$ new gen: " + iface.getName());
+            */
+            try {
+                Interface2WSDLGenerator wsdlGenerator = new Interface2WSDLGenerator(requiresSOAP12);
+                def = wsdlGenerator.generate(iface, wsdlDefinition);
+            } catch (WSDLException e) {
+                throw new RuntimeException(e);
+            }
+
+        } else {
+            /*
+            System.out.println("$$ old gen: " + iface.getName());
+            */
             // Create a package2ns map
             Map<String, String> pkg2nsMap = new HashMap<String, String>();
             for (Operation op : iface.getOperations()) {
@@ -140,27 +196,18 @@
                 register(pkg2nsMap, outputType);
             }
             def = createDefinition(pkg2nsMap, iface.getJavaClass(), requiresSOAP12);
+        }
 
-        } else {  // interface with JAX-WS annotations
+        // for debugging
+        if (printWSDL) {
             try {
-                Interface2WSDLGenerator wsdlGenerator = new Interface2WSDLGenerator();
-                //FIXME: add support for SOAP 1.2
-                def = wsdlGenerator.generate(iface, wsdlDefinition);
+                WSDLWriter writer =  javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
+                writer.writeWSDL(def, System.out);
             } catch (WSDLException e) {
                 throw new RuntimeException(e);
             }
         }
 
-        /*
-        // for debugging
-        try {
-            WSDLWriter writer =  javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
-            writer.writeWSDL(def, System.out);
-        } catch (WSDLException e) {
-            throw new RuntimeException(e);
-        }
-        */
-
         wsdlDefinition.setDefinition(def);
         wsdlInterface.setWsdlDefinition(wsdlDefinition);
         wsdlInterface.setRemotable(true);
@@ -358,7 +405,7 @@
             WSDLLocatorImpl locator = new WSDLLocatorImpl(new ByteArrayInputStream(os.toByteArray()));
             Definition definition = reader.readWSDL(locator);
 
-            processSOAPVersion(definition, requiresSOAP12);
+            // processSOAPVersion(definition, requiresSOAP12);
             processNoArgAndVoidReturnMethods(definition, javaInterface);
 
             return definition;

Modified: incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java?rev=652445&r1=652444&r2=652445&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java
(original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-java2wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/interface2wsdl/Java2WSDLGeneratorTestCase.java
Thu May  1 00:42:00 2008
@@ -47,7 +47,7 @@
         DefaultDataBindingExtensionPoint dataBindings = new DefaultDataBindingExtensionPoint();
         new DataBindingJavaInterfaceProcessor(dataBindings).visitInterface(iface);
         WSDLDefinition wsdlDefinition = new DefaultWSDLFactory().createWSDLDefinition();
-        Interface2WSDLGenerator generator = new Interface2WSDLGenerator();
+        Interface2WSDLGenerator generator = new Interface2WSDLGenerator(false);
         Definition definition = generator.generate(iface, wsdlDefinition);
 
         // print the generated WSDL file and inline schemas



Mime
View raw message