cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r464917 [1/2] - in /incubator/cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/common/ common/src/main/java/org/apache/cxf/tools/util/ java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/ java2wsdl/src/main/java/org/apache/cxf/...
Date Tue, 17 Oct 2006 12:40:37 GMT
Author: mmao
Date: Tue Oct 17 05:40:33 2006
New Revision: 464917

URL: http://svn.apache.org/viewvc?view=rev&rev=464917
Log:
Tools support SOAP1.2

* WSDL2SOAP support SOAP1.2 now, through -soap12 switch
* WSDL2Service support SOAP1.2 now, through -soap12 switch
* Java2WSDL support SOAP1.2 now, through -soap12 switch
* Added unit tests for those features.
* Fixed the create new binding when there is no binding in wsdl.

Added:
    incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl   (with props)
    incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl   (with props)
    incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl   (with props)
    incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12_nobinding.wsdl   (with props)
Modified:
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/BindingGenerator.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/WSDLGenerator.java
    incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
    incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/Messages.properties
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessor.java
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessor.java
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessor.java
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2service.xml
    incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2soap.xml
    incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java
    incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java Tue Oct 17 05:40:33 2006
@@ -85,6 +85,7 @@
     public static final String CFG_TRANSPORT = "transport";
     public static final String CFG_SERVICE = "service";
     public static final String CFG_BINDING_ATTR = "attrbinding";
+    public static final String CFG_SOAP12 = "soap12";
 
     // WSDL2Soap Constants
     public static final String CFG_STYLE = "style";

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/WSDLConstants.java Tue Oct 17 05:40:33 2006
@@ -41,7 +41,7 @@
 
     public static final String BINDING = "Binding";
     public static final String SOAP_HTTP_TRANSPORT = "http://schemas.xmlsoap.org/soap/http";
-    public static final String SOAP12_HTTP_TRANSPORT = "http://www.w3.org/2003/05/soap/bindings/http/";
+    public static final String SOAP12_HTTP_TRANSPORT = "http://www.w3.org/2003/05/soap/bindings/HTTP/";
 
     public static final String DOCUMENT = "document";
     public static final String RPC = "rpc";
@@ -62,15 +62,15 @@
     public static final QName QNAME_BINDING = new QName(NS_WSDL, "binding");
     public static final QName QNAME_DEFINITIONS = new QName(NS_WSDL, "definitions");
     public static final QName QNAME_DOCUMENTATION = new QName(NS_WSDL, "documentation");
-    public static final QName NS_SOAP_BINDING_ADDRESS = new QName("http://schemas.xmlsoap.org/wsdl/soap/",
+    public static final QName NS_SOAP_BINDING_ADDRESS = new QName(SOAP11_NAMESPACE,
                                                                   "address");
     public static final QName NS_XMLHTTP_BINDING_ADDRESS = new QName("http://schemas.xmlsoap.org/wsdl/http/",
                                                                      "address");
-    public static final QName NS_SOAP_BINDING = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "binding");
-    public static final QName NS_SOAP_OPERATION = new QName("http://schemas.xmlsoap.org/wsdl/soap/",
+    public static final QName NS_SOAP_BINDING = new QName(SOAP11_NAMESPACE, "binding");
+    public static final QName NS_SOAP_OPERATION = new QName(SOAP11_NAMESPACE,
                                                             "operation");
-    public static final QName NS_SOAP_BODY = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "body");
-    public static final QName NS_SOAP_FAULT = new QName("http://schemas.xmlsoap.org/wsdl/soap/", "fault");
+    public static final QName NS_SOAP_BODY = new QName(SOAP11_NAMESPACE, "body");
+    public static final QName NS_SOAP_FAULT = new QName(SOAP11_NAMESPACE, "fault");
 
     public static final QName NS_SOAP12_BINDING = new QName("http://schemas.xmlsoap.org/wsdl/soap12/",
                                                             "binding");

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java (original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/util/SOAPBindingUtil.java Tue Oct 17 05:40:33 2006
@@ -24,10 +24,15 @@
 import java.util.*;
 
 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.Port;
+import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.ExtensionRegistry;
 import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.wsdl.extensions.soap.SOAPBody;
@@ -40,11 +45,14 @@
 import javax.wsdl.extensions.soap12.SOAP12Fault;
 import javax.wsdl.extensions.soap12.SOAP12Header;
 import javax.wsdl.extensions.soap12.SOAP12Operation;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.tools.common.ExtensionInvocationHandler;
+import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
 import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
 import org.apache.cxf.tools.common.extensions.soap.SoapBody;
+import org.apache.cxf.tools.common.extensions.soap.SoapFault;
 import org.apache.cxf.tools.common.extensions.soap.SoapHeader;
 import org.apache.cxf.tools.common.extensions.soap.SoapOperation;
 
@@ -249,6 +257,13 @@
         return obj instanceof SOAPBinding || obj instanceof SOAP12Binding;
     }
 
+    public static SoapFault getSoapFault(Object obj) {
+        if (isSOAPFault(obj)) {
+            return getProxy(SoapFault.class, obj);
+        }
+        return null;
+    }
+
     public static boolean isMixedStyle(Binding binding) {
         Iterator ite = binding.getExtensibilityElements().iterator();
         String bindingStyle = "";
@@ -325,4 +340,103 @@
     public static boolean isSOAPFault(Object obj) {
         return obj instanceof SOAPFault || obj instanceof SOAP12Fault;
     }
+
+    public static SoapAddress createSoapAddress(ExtensionRegistry extReg, boolean isSOAP12)
+        throws WSDLException {
+        ExtensibilityElement extElement = null;
+        if (isSOAP12) {
+            extElement = (SOAP12Address)extReg.createExtension(Port.class,
+                                                               WSDLConstants.NS_SOAP12_BINDING_ADDRESS);
+        } else {
+            extElement = (SOAPAddress)extReg.createExtension(Port.class,
+                                                             WSDLConstants.NS_SOAP_BINDING_ADDRESS);
+        }
+        return getSoapAddress(extElement);
+    }
+
+    public static SoapBody createSoapBody(ExtensionRegistry extReg, Class clz, boolean isSOAP12)
+        throws WSDLException {
+        ExtensibilityElement extElement = null;
+        if (isSOAP12) {
+            extElement = (SOAP12Body)extReg.createExtension(clz, new QName(WSDLConstants.SOAP12_NAMESPACE,
+                                                                           "body"));
+        } else {
+            extElement = (SOAPBody)extReg.createExtension(clz, new QName(WSDLConstants.SOAP11_NAMESPACE,
+                                                                         "body"));
+        }
+        return getSoapBody(extElement);
+    }
+
+    public static SoapBinding createSoapBinding(ExtensionRegistry extReg, boolean isSOAP12)
+        throws WSDLException {
+        ExtensibilityElement extElement = null;
+        if (isSOAP12) {
+            extElement = (SOAP12Binding)extReg.createExtension(Binding.class,
+                                                               new QName(WSDLConstants.SOAP12_NAMESPACE,
+                                                                         "binding"));
+            ((SOAP12Binding)extElement).setTransportURI(WSDLConstants.SOAP12_HTTP_TRANSPORT);
+        } else {
+            extElement = (SOAPBinding)extReg.createExtension(Binding.class,
+                                                             new QName(WSDLConstants.SOAP11_NAMESPACE,
+                                                                       "binding"));
+            ((SOAPBinding)extElement).setTransportURI(WSDLConstants.NS_SOAP11_HTTP_BINDING);
+        }
+        return getSoapBinding(extElement);
+    }
+
+    public static SoapOperation createSoapOperation(ExtensionRegistry extReg, boolean isSOAP12)
+        throws WSDLException {
+        ExtensibilityElement extElement = null;
+        if (isSOAP12) {
+            extElement = (SOAP12Operation)extReg.createExtension(BindingOperation.class,
+                                                                 new QName(WSDLConstants.SOAP12_NAMESPACE,
+                                                                           "operation"));
+        } else {
+            extElement = (SOAPOperation)extReg.createExtension(BindingOperation.class,
+                                                               new QName(WSDLConstants.SOAP11_NAMESPACE,
+                                                                         "operation"));
+        }
+        return getSoapOperation(extElement);
+    }
+
+    public static SoapFault createSoapFault(ExtensionRegistry extReg, boolean isSOAP12)
+        throws WSDLException {
+        ExtensibilityElement extElement = null;
+        if (isSOAP12) {
+            extElement = (SOAP12Fault)extReg.createExtension(BindingFault.class,
+                                                             new QName(WSDLConstants.SOAP12_NAMESPACE,
+                                                                       "fault"));
+        } else {
+            extElement = (SOAPFault)extReg.createExtension(BindingFault.class,
+                                                           new QName(WSDLConstants.SOAP11_NAMESPACE,
+                                                                     "fault"));
+        }
+        return getSoapFault(extElement);
+    }
+
+    public static SoapHeader createSoapHeader(ExtensionRegistry extReg, Class clz, boolean isSOAP12)
+        throws WSDLException {
+        ExtensibilityElement extElement = null;
+        if (isSOAP12) {
+            extElement = (SOAP12Header)extReg.createExtension(clz,
+                                                              new QName(WSDLConstants.SOAP12_NAMESPACE,
+                                                                        "header"));
+        } else {
+            extElement = (SOAPHeader)extReg.createExtension(clz,
+                                                            new QName(WSDLConstants.SOAP11_NAMESPACE,
+                                                                      "header"));
+        }
+        return getSoapHeader(extElement);
+    }
+
+
+    public static void addSOAPNamespace(Definition definition, boolean isSOAP12) {
+        Map namespaces = definition.getNamespaces();
+        if (isSOAP12
+            && !namespaces.values().contains(WSDLConstants.SOAP12_NAMESPACE)) {
+            definition.addNamespace("soap12", WSDLConstants.SOAP12_NAMESPACE);
+        } else if (!namespaces.values().contains(WSDLConstants.SOAP11_NAMESPACE)) {
+            definition.addNamespace("soap", WSDLConstants.SOAP12_NAMESPACE);
+        }
+    }    
 }

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/BindingGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/BindingGenerator.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/BindingGenerator.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/BindingGenerator.java Tue Oct 17 05:40:33 2006
@@ -32,20 +32,24 @@
 import javax.wsdl.Definition;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
-import javax.wsdl.extensions.soap.SOAPBody;
-import javax.wsdl.extensions.soap.SOAPHeader;
-import javax.wsdl.extensions.soap.SOAPOperation;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.WSDLConstants;
+import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
+import org.apache.cxf.tools.common.extensions.soap.SoapBody;
+import org.apache.cxf.tools.common.extensions.soap.SoapFault;
+import org.apache.cxf.tools.common.extensions.soap.SoapHeader;
+import org.apache.cxf.tools.common.extensions.soap.SoapOperation;
 import org.apache.cxf.tools.common.model.JavaMethod;
 import org.apache.cxf.tools.common.model.JavaParameter;
 import org.apache.cxf.tools.common.model.WSDLModel;
 import org.apache.cxf.tools.common.model.WSDLParameter;
 import org.apache.cxf.tools.java2wsdl.processor.JavaToWSDLProcessor;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
+
 
 public class BindingGenerator {
     private static final Logger LOG = LogUtils.getL7dLogger(JavaToWSDLProcessor.class);
@@ -60,19 +64,22 @@
     }
 
     public void generate() {
+        generate(false);
+    }
+    
+    public void generate(boolean isSOAP12) {
         Binding binding = definition.createBinding();
 
         binding.setQName(new QName(WSDLConstants.NS_WSDL, wmodel.getPortTypeName() + "Binding"));
-        binding.setPortType(definition.getPortType(new QName(wmodel.getTargetNameSpace(), wmodel
-            .getPortTypeName())));
+        binding.setPortType(definition.getPortType(new QName(wmodel.getTargetNameSpace(),
+                                                             wmodel.getPortTypeName())));
 
-        // genearte the soap binding
+        // default to genearte the soap 1.1 binding
 
-        javax.wsdl.extensions.soap.SOAPBinding soapBinding;
+        SoapBinding soapBinding = null;
         try {
-            soapBinding = (javax.wsdl.extensions.soap.SOAPBinding)extensionRegistry
-                .createExtension(Binding.class, new QName(WSDLConstants.SOAP11_NAMESPACE, "binding"));
-            soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+            soapBinding = SOAPBindingUtil.createSoapBinding(extensionRegistry, isSOAP12);
+            
             soapBinding.setStyle(wmodel.getStyle().toString().toLowerCase());
             binding.addExtensibilityElement(soapBinding);
         } catch (WSDLException e) {
@@ -80,88 +87,72 @@
             e.printStackTrace();
         }
 
-        generateBindingOperation(binding);
+        try {
+            generateBindingOperation(binding, isSOAP12);
+        } catch (WSDLException e) {
+            throw new ToolException(e.getMessage(), e);
+        }
         binding.setUndefined(false);
         definition.addBinding(binding);
 
     }
 
-    private void generateBindingOperation(Binding binding) {
+    private void generateBindingOperation(Binding binding, boolean isSOAP12) throws WSDLException {
         for (JavaMethod jmethod : wmodel.getJavaMethods()) {
             BindingOperation bindOperation = definition.createBindingOperation();
             bindOperation.setName(jmethod.getName());
-            generateBindingOperationInputOutPut(bindOperation, jmethod);
+            generateBindingOperationInputOutPut(bindOperation, jmethod, isSOAP12);
             binding.addBindingOperation(bindOperation);
         }
 
     }
 
-    private void generateBindingOperationInputOutPut(BindingOperation operation, JavaMethod jmethod) {
+    private void generateBindingOperationInputOutPut(BindingOperation operation,
+                                                     JavaMethod jmethod,
+                                                     boolean isSOAP12)
+        throws WSDLException {
         // generate soap binding action
-        SOAPOperation soapOperation = generateSoapAction();
+
+        SoapOperation soapOperation = SOAPBindingUtil.createSoapOperation(extensionRegistry, isSOAP12);
+        
         soapOperation.setStyle(jmethod.getSoapStyle().name().toLowerCase());
         if (jmethod.getSoapAction() != null && !jmethod.getSoapAction().equals("")) {
             soapOperation.setSoapActionURI(jmethod.getSoapAction());
         }
         operation.addExtensibilityElement(soapOperation);
 
-        generateInputSoapBody(jmethod, operation, jmethod.getRequest());
-
-        generateOutputSoapBody(jmethod, operation, jmethod.getResponse());
+        generateInputSoapBody(jmethod, operation, jmethod.getRequest(), isSOAP12);
+        
+        generateOutputSoapBody(jmethod, operation, jmethod.getResponse(), isSOAP12);
 
         for (org.apache.cxf.tools.common.model.WSDLException ex : jmethod.getWSDLExceptions()) {
 
             BindingFault bindingFault = definition.createBindingFault();
             bindingFault.setName(ex.getExcpetionClass().getSimpleName());
             operation.addBindingFault(bindingFault);
-            javax.wsdl.extensions.soap.SOAPFault soapFault = null;
-            try {
-                soapFault = (javax.wsdl.extensions.soap.SOAPFault)extensionRegistry
-                    .createExtension(BindingFault.class, new QName(WSDLConstants.SOAP11_NAMESPACE, "fault"));
-                soapFault.setUse("literal");
-                soapFault.setName(ex.getExcpetionClass().getSimpleName());
-            } catch (WSDLException e) {
-                throw new ToolException(e.getMessage(), e);
-            }
+            SoapFault soapFault = SOAPBindingUtil.createSoapFault(extensionRegistry, isSOAP12);
+            soapFault.setUse("literal");
+            soapFault.setName(ex.getExcpetionClass().getSimpleName());
             bindingFault.addExtensibilityElement(soapFault);
 
         }
 
     }
 
-    private SOAPOperation generateSoapAction() {
-        SOAPOperation soapOperation = null;
-        try {
-            soapOperation = (SOAPOperation)extensionRegistry
-                .createExtension(BindingOperation.class, new QName(WSDLConstants.SOAP11_NAMESPACE,
-                                                                   "operation"));
-        } catch (WSDLException e) {
-            throw new ToolException(e.getMessage(), e);
-        }
-
-        return soapOperation;
-    }
-
-    private void generateOutputSoapBody(JavaMethod jmethod, BindingOperation operation, WSDLParameter param) {
+    private void generateOutputSoapBody(JavaMethod jmethod,
+                                        BindingOperation operation,
+                                        WSDLParameter param,
+                                        boolean isSOAP12) throws WSDLException {
         if (param == null) {
             return;
         }
 
-        SOAPBody body = null;
-
         BindingOutput bindingOutput = definition.createBindingOutput();
         bindingOutput.setName(param.getName());
 
         operation.setBindingOutput(bindingOutput);
-
-        try {
-            body = (SOAPBody)extensionRegistry.createExtension(BindingOutput.class,
-                                                               new QName(WSDLConstants.SOAP11_NAMESPACE,
-                                                                         "body"));
-        } catch (WSDLException e1) {
-            throw new ToolException(e1.getMessage(), e1);
-        }
-
+        
+        SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingOutput.class, isSOAP12);
         if (jmethod.getSoapUse() == SOAPBinding.Use.LITERAL) {
             body.setUse("literal");
         } else {
@@ -181,20 +172,14 @@
                 parts.add(parameter.getPartName());
             }
             body.setParts(parts);
-            SOAPHeader soapHeader = null;
+            SoapHeader soapHeader = null;
             for (JavaParameter jp : headerParams) {
-
-                try {
-                    soapHeader = (SOAPHeader)extensionRegistry
-                        .createExtension(BindingOutput.class, new QName(WSDLConstants.SOAP11_NAMESPACE,
-                                                                        "header"));
-                    soapHeader.setMessage(new QName(param.getTargetNamespace(), param.getName()));
-                    soapHeader.setPart(jp.getPartName());
-                    soapHeader.setUse("literal");
-
-                } catch (WSDLException e) {
-                    throw new ToolException(e.getMessage(), e);
-                }
+                soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry,
+                                                              BindingOutput.class,
+                                                              isSOAP12);
+                soapHeader.setMessage(new QName(param.getTargetNamespace(), param.getName()));
+                soapHeader.setPart(jp.getPartName());
+                soapHeader.setUse("literal");
             }
 
             if (jmethod.getSoapStyle() == SOAPBinding.Style.RPC) {
@@ -207,25 +192,19 @@
 
     }
 
-    private void generateInputSoapBody(JavaMethod jmethod, BindingOperation operation, WSDLParameter param) {
+    private void generateInputSoapBody(JavaMethod jmethod,
+                                       BindingOperation operation,
+                                       WSDLParameter param,
+                                       boolean isSOAP12) throws WSDLException {
         if (param == null) {
             return;
         }
-        SOAPBody body = null;
-
         BindingInput bindingInput = definition.createBindingInput();
         bindingInput.setName(param.getName());
 
         operation.setBindingInput(bindingInput);
 
-        try {
-            body = (SOAPBody)extensionRegistry.createExtension(BindingInput.class,
-                                                               new QName(WSDLConstants.SOAP11_NAMESPACE,
-                                                                         "body"));
-        } catch (WSDLException e1) {
-            throw new ToolException(e1.getMessage(), e1);
-        }
-
+        SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingInput.class, isSOAP12);
         if (jmethod.getSoapUse() == SOAPBinding.Use.LITERAL) {
             body.setUse("literal");
         } else {
@@ -246,23 +225,16 @@
                 parts.add(parameter.getPartName());
             }
             body.setParts(parts);
-            SOAPHeader soapHeader = null;
+            SoapHeader soapHeader = null;
             for (JavaParameter jp : headerParams) {
-
-                try {
-                    soapHeader = (SOAPHeader)extensionRegistry
-                        .createExtension(BindingInput.class, new QName(WSDLConstants.SOAP11_NAMESPACE,
-                                                                       "header"));
-
-                    soapHeader.setMessage(new QName(param.getTargetNamespace(), param.getName()));
-                    soapHeader.setPart(jp.getPartName());
-                    soapHeader.setUse("literal");
-
-                } catch (WSDLException e) {
-                    throw new ToolException(e.getMessage(), e);
-                }
+                soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry,
+                                                              BindingInput.class,
+                                                              isSOAP12);
+                soapHeader.setMessage(new QName(param.getTargetNamespace(), param.getName()));
+                soapHeader.setPart(jp.getPartName());
+                soapHeader.setUse("literal");
             }
-
+            
             if (jmethod.getSoapStyle() == SOAPBinding.Style.RPC) {
                 body.setNamespaceURI(param.getTargetNamespace());
             }

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/ServiceGenerator.java Tue Oct 17 05:40:33 2006
@@ -25,12 +25,13 @@
 import javax.wsdl.Service;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
-import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.WSDLConstants;
+import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
 import org.apache.cxf.tools.common.model.WSDLModel;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
 
 public class ServiceGenerator {
     private static final String ADDRESS_URI = "http://localhost/changme";
@@ -46,6 +47,10 @@
     }
     
     public void generate() {
+        generate(false);
+    }
+    
+    public void generate(boolean isSOAP12) {
         Service service = definition.createService();
         service.setQName(new QName(WSDLConstants.WSDL_PREFIX, wmodel.getServiceName()));
         Port port = definition.createPort();
@@ -54,10 +59,9 @@
         String targetNameSpace = wmodel.getTargetNameSpace();
         binding.setQName(new QName(targetNameSpace, wmodel.getPortTypeName() + "Binding"));
         port.setBinding(binding);
-        SOAPAddress soapAddress = null;
+        SoapAddress soapAddress = null;
         try {
-            soapAddress = (SOAPAddress)extensionRegistry
-                .createExtension(Port.class, new QName(WSDLConstants.SOAP11_NAMESPACE, "address"));
+            soapAddress = SOAPBindingUtil.createSoapAddress(extensionRegistry, isSOAP12);
             soapAddress.setLocationURI(ADDRESS_URI);
         } catch (WSDLException e) {
             throw new ToolException(e.getMessage(), e);

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/WSDLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/WSDLGenerator.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/WSDLGenerator.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/generator/WSDLGenerator.java Tue Oct 17 05:40:33 2006
@@ -27,6 +27,7 @@
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.model.WSDLModel;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
 
 public class WSDLGenerator {
     private final WSDLModel wmodel;
@@ -59,13 +60,17 @@
         MessagePortTypeGenerator messagePortTypeGen = new MessagePortTypeGenerator(wmodel);
         messagePortTypeGen.generate();
         BindingGenerator bindingGen = new BindingGenerator(wmodel);
-        bindingGen.generate();
+        bindingGen.generate(isSOAP12());
         ServiceGenerator serviceGen = new ServiceGenerator(wmodel);
-        serviceGen.generate();
+        serviceGen.generate(isSOAP12());
         writeDefinition();
 
     }
 
+    private boolean isSOAP12() {
+        return env.optionSet(ToolConstants.CFG_SOAP12);
+    }
+
     private void preGenerate() {
         Object obj = env.get(ToolConstants.CFG_OUTPUTFILE);
         wsdlFile = obj == null ? "./" + wmodel.getServiceName() + ".wsdl" : (String)obj;
@@ -78,7 +83,7 @@
         wmodel.setPortName(portTypeName);
 
     }
-
+   
     private boolean writeDefinition() {
 
         WSDLWriter writer = wsdlFactory.newWSDLWriter();
@@ -92,6 +97,7 @@
         }
 
         try {
+            SOAPBindingUtil.addSOAPNamespace(definition, isSOAP12());
             writer.writeWSDL(this.definition, outstream);
         } catch (javax.wsdl.WSDLException e) {
             throw new ToolException(e.getMessage(), e);

Modified: incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/main/java/org/apache/cxf/tools/java2wsdl/java2wsdl.xml Tue Oct 17 05:40:33 2006
@@ -56,7 +56,13 @@
 		    <annotation>class-path</annotation>
 		</associatedArgument>
 	    </option>
-	    
+
+	    <option id="soap12" maxOccurs="1">
+		<annotation>
+		    Specify to generate SOAP 1.2 binding
+		</annotation>
+		<switch>soap12</switch>
+	    </option>
 
 	    <option id="tns" maxOccurs="1">
 		<annotation>

Modified: incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java (original)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToWSDLProcessorTest.java Tue Oct 17 05:40:33 2006
@@ -20,15 +20,21 @@
 package org.apache.cxf.tools.java2wsdl.processor;
 
 import java.io.File;
+import java.util.Iterator;
 
+import javax.wsdl.Binding;
 import javax.wsdl.Definition;
+import javax.wsdl.Port;
 import javax.wsdl.Service;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.helpers.WSDLHelper;
-
 import org.apache.cxf.tools.common.ToolConstants;
-
+import org.apache.cxf.tools.common.WSDLConstants;
+import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
 import org.apache.cxf.tools.wsdl2java.processor.WSDLToJavaProcessor;
 
 public class JavaToWSDLProcessorTest extends ProcessorTestBase {
@@ -39,28 +45,26 @@
     private String serviceName = "cxfService";
     private WSDLHelper wsdlHelper = new WSDLHelper();
     private File classFile;
-    
+
     public void setUp() throws Exception {
-       
-        
+
         super.setUp();
         wj2Processor = new WSDLToJavaProcessor();
         j2wProcessor = new JavaToWSDLProcessor();
         classFile = new java.io.File(output.getCanonicalPath() + "/classes");
         classFile.mkdir();
         System.setProperty("java.class.path", getClassPath() + classFile.getCanonicalPath()
-                           + File.separatorChar);
+                                              + File.separatorChar);
     }
-    
+
     public void tearDown() {
         super.tearDown();
         j2wProcessor = null;
         wj2Processor = null;
     }
-    
 
     public void testAsyn() throws Exception {
-        
+
         env.put(ToolConstants.CFG_COMPILE, "compile");
         env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
         env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
@@ -68,7 +72,6 @@
         wj2Processor.setEnvironment(env);
         wj2Processor.process();
 
-
         env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/asyn.wsdl");
         env.put(ToolConstants.CFG_CLASSNAME, "org.apache.hello_world_async_soap_http.GreeterAsync");
         env.put(ToolConstants.CFG_TNS, tns);
@@ -96,27 +99,25 @@
         wj2Processor.setEnvironment(env);
         wj2Processor.process();
 
-
         env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/doc_wrapped_bare.wsdl");
         env.put(ToolConstants.CFG_CLASSNAME, "org.apache.hello_world_doc_wrapped_bare.Greeter");
         env.put(ToolConstants.CFG_TNS, tns);
         env.put(ToolConstants.CFG_SERVICENAME, serviceName);
         j2wProcessor.setEnvironment(env);
         j2wProcessor.process();
-        
+
         File wsdlFile = new File(output, "doc_wrapped_bare.wsdl");
         assertTrue("Fail to generate wsdl file", wsdlFile.exists());
-        
+
         Definition def = wsdlHelper.getDefinition(wsdlFile);
         Service wsdlService = def.getService(new QName(tns, serviceName));
         assertNotNull("Generate WSDL Service Error", wsdlService);
-        
+
         File schemaFile = new File(output, "schema1.xsd");
         assertTrue("Fail to generate schema file", schemaFile.exists());
 
     }
-    
-    
+
     public void testDocLitUseClassPathFlag() throws Exception {
         env.put(ToolConstants.CFG_COMPILE, "compile");
         env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
@@ -124,7 +125,7 @@
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/java2wsdl_wsdl/hello_world_doc_lit.wsdl"));
         wj2Processor.setEnvironment(env);
         wj2Processor.process();
- 
+
         System.setProperty("java.class.path", "");
         env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/doc_lit.wsdl");
         env.put(ToolConstants.CFG_CLASSNAME, "org.apache.hello_world_doc_lit.Greeter");
@@ -135,16 +136,16 @@
         j2wProcessor.process();
         File wsdlFile = new File(output, "doc_lit.wsdl");
         assertTrue("Generate Wsdl Fail", wsdlFile.exists());
-        
+
         Definition def = wsdlHelper.getDefinition(wsdlFile);
         Service wsdlService = def.getService(new QName(tns, serviceName));
         assertNotNull("Generate WSDL Service Error", wsdlService);
-        
+
         File schemaFile = new File(output, "schema1.xsd");
         assertTrue("Generate schema file Fail", schemaFile.exists());
-        
+
     }
-    
+
     public void testRPCLit() throws Exception {
         env.put(ToolConstants.CFG_COMPILE, "compile");
         env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
@@ -152,30 +153,77 @@
         env.put(ToolConstants.CFG_WSDLURL, getLocation("/java2wsdl_wsdl/hello_world_rpc_lit.wsdl"));
         wj2Processor.setEnvironment(env);
         wj2Processor.process();
-   
-        env.put(ToolConstants.CFG_OUTPUTFILE,
-                output.getPath() + "/rpc_lit.wsdl");
+
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/rpc_lit.wsdl");
         env.put(ToolConstants.CFG_CLASSNAME, "org.apache.hello_world_rpclit.GreeterRPCLit");
         env.put(ToolConstants.CFG_TNS, tns);
         env.put(ToolConstants.CFG_SERVICENAME, serviceName);
-        
+
         j2wProcessor.setEnvironment(env);
         j2wProcessor.process();
         File wsdlFile = new File(output, "rpc_lit.wsdl");
         assertTrue(wsdlFile.exists());
-        
+
         Definition def = wsdlHelper.getDefinition(wsdlFile);
         Service wsdlService = def.getService(new QName(tns, serviceName));
         assertNotNull("Generate WSDL Service Error", wsdlService);
-        
-        
-        File schemaFile = new File(output, "schema1.xsd");        
+
+        File schemaFile = new File(output, "schema1.xsd");
         assertTrue(schemaFile.exists());
-        File schemaFile2 = new File(output, "schema2.xsd");        
+        File schemaFile2 = new File(output, "schema2.xsd");
         assertTrue(schemaFile2.exists());
     }
 
-    
+    public void testSOAP12() throws Exception {
+        env.put(ToolConstants.CFG_COMPILE, "compile");
+        env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+        env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + "/classes");
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/java2wsdl_wsdl/hello_world_soap12.wsdl"));
+        wj2Processor.setEnvironment(env);
+        wj2Processor.process();
+
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/soap12.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.hello_world_soap12_http.Greeter");
+        env.put(ToolConstants.CFG_SERVICENAME, serviceName);
+        env.put(ToolConstants.CFG_SOAP12, "soap12");
+
+        j2wProcessor.setEnvironment(env);
+        j2wProcessor.process();
+        File wsdlFile = new File(output, "soap12.wsdl");
+        assertTrue(wsdlFile.exists());
+        assertTrue("WSDL file: " + wsdlFile.toString() + " is empty", wsdlFile.length() > 0);
+
+        Definition def = wsdlHelper.getDefinition(wsdlFile);
+        Service wsdlService = def.getService(new QName(def.getTargetNamespace(), serviceName));
+        assertNotNull("Generate WSDL Service Error", wsdlService);
+
+        File schemaFile = new File(output, "schema1.xsd");
+        assertTrue(schemaFile.exists());
+        Binding binding = def.getBinding(new QName(def.getTargetNamespace(), "GreeterBinding"));
+        assertNotNull(binding);
+
+        Iterator it = binding.getExtensibilityElements().iterator();
+
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
+            assertTrue(obj instanceof SOAP12Binding);
+            SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
+            assertNotNull(soapBinding);
+            assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
+            assertTrue(WSDLConstants.SOAP12_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
+        }
+        Port port = wsdlService.getPort("GreeterPort");
+        assertNotNull(port);
+
+        it = port.getExtensibilityElements().iterator();
+        while (it.hasNext()) {
+            Object obj = it.next();
+            assertTrue(SOAPBindingUtil.isSOAPAddress(obj));
+            assertTrue(obj instanceof SOAP12Address);
+        }
+    }
+
     private String getLocation(String wsdlFile) {
         return JavaToWSDLProcessorTest.class.getResource(wsdlFile).getFile();
     }

Added: incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl?view=auto&rev=464917
==============================================================================
--- incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl (added)
+++ incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl Tue Oct 17 05:40:33 2006
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<definitions name="HelloWorld"
+	     xmlns="http://schemas.xmlsoap.org/wsdl/"
+	     xmlns:tns="http://apache.org/hello_world_soap12_http"
+	     xmlns:x1="http://apache.org/hello_world_soap12_http/types"
+	     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	     targetNamespace="http://apache.org/hello_world_soap12_http"
+	     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
+    <wsdl:types>
+	<schema targetNamespace="http://apache.org/hello_world_soap12_http/types" 
+		xmlns="http://www.w3.org/2001/XMLSchema" 
+		xmlns:x1="http://apache.org/hello_world_soap12_http/types" 
+		elementFormDefault="qualified">
+	    <element name="sayHi">
+		<complexType/>
+	    </element>
+	    <element name="sayHiResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+        </schema>
+    </wsdl:types>
+
+    <wsdl:message name="sayHiRequest">
+        <wsdl:part name="in" element="x1:sayHi"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part name="out" element="x1:sayHiResponse"/>
+    </wsdl:message>
+
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+            <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+	<soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" />
+	<operation name="sayHi">
+	    <soap12:operation style="document" soapAction=""/>
+	    <input>
+		<soap12:body use="literal" />
+	    </input>
+	    <output>
+		<soap12:body use="literal" />
+	    </output>
+	</operation>
+    </wsdl:binding>
+
+
+</definitions>

Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/java2wsdl/src/test/resources/java2wsdl_wsdl/hello_world_soap12.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/Messages.properties?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/Messages.properties (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/Messages.properties Tue Oct 17 05:40:33 2006
@@ -41,7 +41,7 @@
 SOAPBINDING_STYLE_NOT_PROVIEDED = For rpc style binding, soap binding namespace (-n) must be provided
 FAIL_TO_CREATE_SOAPBINDING = Fail to create soapbinding
 FAIL_TO_CREATE_XMLBINDING = Fail to create xml binding
-FAIl_TO_CREATE_SOAPADDRESS = Fail to create soap address
+FAIL_TO_CREATE_SOAPADDRESS = Fail to create soap address
 
 SKIP_OVERLOADED_OPERATION=Skipping overloaded operation: {0}
 NO_INPUT_MESSAGE=Problem outputting method for {0} as no input message was found for input named {1}

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessor.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessor.java (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessor.java Tue Oct 17 05:40:33 2006
@@ -29,7 +29,6 @@
 import javax.wsdl.Service;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
-import javax.wsdl.extensions.soap.SOAPAddress;
 import javax.wsdl.xml.WSDLWriter;
 import javax.xml.namespace.QName;
 
@@ -39,6 +38,8 @@
 import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.tools.common.extensions.jms.JMSAddress;
 import org.apache.cxf.tools.common.extensions.jms.JMSAddressSerializer;
+import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
 
 public class WSDLToServiceProcessor extends AbstractWSDLToProcessor {
 
@@ -101,6 +102,10 @@
         return (port == null) ? false : true;
     }
 
+    private boolean isSOAP12() {
+        return env.optionSet(ToolConstants.CFG_SOAP12);
+    }
+
     private boolean isBindingExisted() {
         Map bindings = wsdlDefinition.getBindings();
         if (bindings == null) {
@@ -142,7 +147,7 @@
         try {
             wsdlWriter.writeWSDL(wsdlDefinition, outputWriter);
         } catch (WSDLException wse) {
-            Message msg = new Message("FAIl_TO_WRITE_WSDL", LOG);
+            Message msg = new Message("FAIL_TO_WRITE_WSDL", LOG);
             throw new ToolException(msg, wse);
         }
         try {
@@ -160,14 +165,14 @@
             extReg = wsdlFactory.newPopulatedExtensionRegistry();
         }
         if ("http".equalsIgnoreCase((String)env.get(ToolConstants.CFG_TRANSPORT))) {
-            SOAPAddress soapAddress = null;
+            SoapAddress soapAddress = null;
             try {
-                soapAddress = (SOAPAddress)extReg.createExtension(Port.class,
-                                                                  WSDLConstants.NS_SOAP_BINDING_ADDRESS);
+                soapAddress = SOAPBindingUtil.createSoapAddress(extReg, isSOAP12());
             } catch (WSDLException wse) {
-                Message msg = new Message("FAIl_TO_CREATE_SOAPADDRESS", LOG);
+                Message msg = new Message("FAIL_TO_CREATE_SOAPADDRESS", LOG);
                 throw new ToolException(msg, wse);
             }
+            
             if (env.get(ToolConstants.CFG_ADDRESS) != null) {
                 soapAddress.setLocationURI((String)env.get(ToolConstants.CFG_ADDRESS));
             } else {

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessor.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessor.java (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessor.java Tue Oct 17 05:40:33 2006
@@ -38,10 +38,6 @@
 import javax.wsdl.PortType;
 import javax.wsdl.WSDLException;
 import javax.wsdl.extensions.ExtensionRegistry;
-import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPBody;
-import javax.wsdl.extensions.soap.SOAPFault;
-import javax.wsdl.extensions.soap.SOAPOperation;
 import javax.wsdl.xml.WSDLWriter;
 import javax.xml.namespace.QName;
 
@@ -49,6 +45,12 @@
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
 import org.apache.cxf.tools.common.WSDLConstants;
+import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
+import org.apache.cxf.tools.common.extensions.soap.SoapBody;
+import org.apache.cxf.tools.common.extensions.soap.SoapFault;
+import org.apache.cxf.tools.common.extensions.soap.SoapOperation;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
+
 
 public class WSDLToSoapProcessor extends AbstractWSDLToProcessor {
 
@@ -67,6 +69,10 @@
         doAppendBinding();
     }
 
+    private boolean isSOAP12() {
+        return env.optionSet(ToolConstants.CFG_SOAP12);        
+    }
+
     private void validate() throws ToolException {
         if (isBindingExisted()) {
             Message msg = new Message("BINDING_ALREADY_EXIST", LOG);
@@ -159,8 +165,8 @@
     private void doAppendBinding() throws ToolException {
         if (binding == null) {
             binding = wsdlDefinition.createBinding();
-            binding.setQName(new QName(wsdlDefinition.getTargetNamespace(), (String)env
-                .get(ToolConstants.CFG_BINDING)));
+            binding.setQName(new QName(wsdlDefinition.getTargetNamespace(),
+                                       (String)env.get(ToolConstants.CFG_BINDING)));
             binding.setUndefined(false);
             binding.setPortType(portType);
         }
@@ -189,15 +195,17 @@
         if (extReg == null) {
             extReg = wsdlFactory.newPopulatedExtensionRegistry();
         }
-        SOAPBinding soapBinding = null;
+
+        SOAPBindingUtil.addSOAPNamespace(wsdlDefinition, isSOAP12());
+        
+        SoapBinding soapBinding = null;
         try {
-            soapBinding = (SOAPBinding)extReg.createExtension(Binding.class, WSDLConstants.NS_SOAP_BINDING);
+            soapBinding = SOAPBindingUtil.createSoapBinding(extReg, isSOAP12());
         } catch (WSDLException wse) {
             Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
             throw new ToolException(msg, wse);
         }
         soapBinding.setStyle((String)env.get(ToolConstants.CFG_STYLE));
-        soapBinding.setTransportURI(WSDLConstants.NS_SOAP11_HTTP_BINDING);
         binding.addExtensibilityElement(soapBinding);
     }
 
@@ -236,10 +244,10 @@
         if (extReg == null) {
             extReg = wsdlFactory.newPopulatedExtensionRegistry();
         }
-        SOAPOperation soapOperation = null;
+        SoapOperation soapOperation = null;
+        
         try {
-            soapOperation = (SOAPOperation)extReg.createExtension(BindingOperation.class,
-                                                                  WSDLConstants.NS_SOAP_OPERATION);
+            soapOperation = SOAPBindingUtil.createSoapOperation(extReg, isSOAP12());
         } catch (WSDLException wse) {
             Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
             throw new ToolException(msg, wse);
@@ -269,13 +277,13 @@
         return bo;
     }
 
-    private SOAPBody getSoapBody(Class parent) throws ToolException {
+    private SoapBody getSoapBody(Class parent) throws ToolException {
         if (extReg == null) {
             extReg = wsdlFactory.newPopulatedExtensionRegistry();
         }
-        SOAPBody soapBody = null;
+        SoapBody soapBody = null;
         try {
-            soapBody = (SOAPBody)extReg.createExtension(parent, WSDLConstants.NS_SOAP_BODY);
+            soapBody = SOAPBindingUtil.createSoapBody(extReg, parent, isSOAP12());
         } catch (WSDLException wse) {
             Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
             throw new ToolException(msg, wse);
@@ -305,9 +313,9 @@
         if (extReg == null) {
             extReg = wsdlFactory.newPopulatedExtensionRegistry();
         }
-        SOAPFault soapFault = null;
+        SoapFault  soapFault = null;
         try {
-            soapFault = (SOAPFault)extReg.createExtension(BindingFault.class, WSDLConstants.NS_SOAP_FAULT);
+            soapFault = SOAPBindingUtil.createSoapFault(extReg, isSOAP12());
         } catch (WSDLException wse) {
             Message msg = new Message("FAIL_TO_CREATE_SOAPBINDING", LOG);
             throw new ToolException(msg, wse);

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessor.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessor.java (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/WSDLToXMLProcessor.java Tue Oct 17 05:40:33 2006
@@ -273,7 +273,7 @@
             xmlHttpAddress = (XMLHttpAddress)extReg.createExtension(Port.class,
                                                                     WSDLConstants.NS_XMLHTTP_BINDING_ADDRESS);
         } catch (WSDLException wse) {
-            Message msg = new Message("FAIl_TO_CREATE_SOAPADDRESS", LOG);
+            Message msg = new Message("FAIL_TO_CREATE_SOAPADDRESS", LOG);
             throw new ToolException(msg);
         }
         if (env.get(ToolConstants.CFG_ADDRESS) != null) {

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java Tue Oct 17 05:40:33 2006
@@ -199,7 +199,7 @@
         try {
             writer = fw.getWriter("", newName);
         } catch (IOException ioe) {
-            Message msg = new Message("FAIl_TO_WRITE_FILE", LOG, env.get(ToolConstants.CFG_OUTPUTDIR)
+            Message msg = new Message("FAIL_TO_WRITE_FILE", LOG, env.get(ToolConstants.CFG_OUTPUTDIR)
                                     + System.getProperty("file.seperator") + newName);
             throw new ToolException(msg, ioe);
         }

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2service.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2service.xml?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2service.xml (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2service.xml Tue Oct 17 05:40:33 2006
@@ -86,6 +86,15 @@
 				    <annotation>address</annotation>
 				</associatedArgument>
 		</option>
+
+
+		<option id="soap12" maxOccurs="1">
+		    <annotation>
+			Specifies the SOAP version to SOAP 1.2
+		    </annotation>
+		    <switch>soap12</switch>
+		</option>
+
 	
 		<option id="destinationStyle" maxOccurs="1">
 		     	 <annotation>

Modified: incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2soap.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2soap.xml?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2soap.xml (original)
+++ incubator/cxf/trunk/tools/misctools/src/main/java/org/apache/cxf/tools/misc/wsdl2soap.xml Tue Oct 17 05:40:33 2006
@@ -52,6 +52,13 @@
 					<annotation>binding-name</annotation>
 				</associatedArgument>
 			</option>
+
+			<option id="soap12" maxOccurs="1">
+			    <annotation>
+				Specifies to generate SOAP 1.2 binding
+			    </annotation>
+			    <switch>soap12</switch>
+			</option>
 			
 			<option id="outputdir" maxOccurs="1">
                         <annotation>

Modified: incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java (original)
+++ incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToServiceProcessorTest.java Tue Oct 17 05:40:33 2006
@@ -24,6 +24,7 @@
 
 import javax.wsdl.Service;
 import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.tools.common.ProcessorTestBase;
@@ -84,6 +85,49 @@
         } catch (ToolException e) {
             fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
         }
+    }
+
+    public void testNewServiceSoap12() throws Exception {
+        String[] args = new String[] {"-soap12", "-transport", "http", 
+                                      "-e", "SOAPService", "-p", "SoapPort", "-n",
+                                      "Greeter_SOAPBinding", "-a", 
+                                      "http://localhost:9000/SOAPService/SoapPort", "-d",
+                                      output.getCanonicalPath(),
+                                      getLocation("/misctools_wsdl/hello_world_soap12.wsdl")};
+        WSDLToService.main(args);
+
+        File outputFile = new File(output, "hello_world_soap12-service.wsdl");
+        assertTrue("New wsdl file is not generated", outputFile.exists());
+        WSDLToServiceProcessor processor = new WSDLToServiceProcessor();
+        processor.setEnvironment(env);
+        try {
+            processor.parseWSDL(outputFile.getAbsolutePath());
+            Service service = processor.getWSDLDefinition().getService(
+                                                                       new QName(processor
+                                                                           .getWSDLDefinition()
+                                                                           .getTargetNamespace(),
+                                                                                 "SOAPService"));
+            if (service == null) {
+                fail("Element wsdl:service serviceins Missed!");
+            }
+            Iterator it = service.getPort("SoapPort").getExtensibilityElements().iterator();
+            if (service == null) {
+                fail("Element wsdl:port portins Missed!");
+            }
+
+            while (it.hasNext()) {
+                Object obj = it.next();
+                if (obj instanceof SOAP12Address) {
+                    SOAP12Address soapAddress = (SOAP12Address)obj;
+                    assertNotNull(soapAddress.getLocationURI());
+                    assertEquals("http://localhost:9000/SOAPService/SoapPort", soapAddress.getLocationURI());
+                    break;
+                }
+            }
+        } catch (ToolException e) {
+            fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
+        }
+        
     }
 
     public void testDefaultLocation() throws Exception {

Modified: incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java?view=diff&rev=464917&r1=464916&r2=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java (original)
+++ incubator/cxf/trunk/tools/misctools/src/test/java/org/apache/cxf/tools/misc/processor/WSDLToSoapProcessorTest.java Tue Oct 17 05:40:33 2006
@@ -26,11 +26,18 @@
 import javax.wsdl.BindingFault;
 import javax.wsdl.BindingInput;
 import javax.wsdl.BindingOperation;
+import javax.wsdl.extensions.soap.SOAPBinding;
+import javax.wsdl.extensions.soap.SOAPBody;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Binding;
+import javax.wsdl.extensions.soap12.SOAP12Body;
+import javax.wsdl.extensions.soap12.SOAP12Operation;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.common.WSDLConstants;
 import org.apache.cxf.tools.common.extensions.soap.SoapBinding;
 import org.apache.cxf.tools.common.extensions.soap.SoapBody;
 import org.apache.cxf.tools.common.extensions.soap.SoapOperation;
@@ -190,6 +197,137 @@
         }
     }
 
+    public void testNewSoap12Binding() throws Exception {
+        String[] args = new String[] {"-i", "Greeter", 
+                                      "-soap12",                                      
+                                      "-b", "Greeter_SOAP12Binding",
+                                      "-d", output.getCanonicalPath(), 
+                                      "-o", "hello_world_soap12_newbinding.wsdl",
+                                      getLocation("/misctools_wsdl/hello_world_soap12_nobinding.wsdl")};
+        WSDLToSoap.main(args);
+
+        File outputFile = new File(output, "hello_world_soap12_newbinding.wsdl");
+        
+        assertTrue("New wsdl file is not generated", outputFile.exists());
+        assertTrue("Generated file is empty!", outputFile.length() > 0);
+        
+        WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
+        processor.setEnvironment(env);
+        try {
+            processor.parseWSDL(outputFile.getAbsolutePath());
+            Binding binding = processor.getWSDLDefinition()
+                .getBinding(
+                            new QName(processor.getWSDLDefinition().getTargetNamespace(),
+                                      "Greeter_SOAP12Binding"));
+            if (binding == null) {
+                fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
+            }
+            Iterator it = binding.getExtensibilityElements().iterator();
+
+            while (it.hasNext()) {
+                Object obj = it.next();                
+                assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
+                assertTrue(obj instanceof SOAP12Binding);
+                SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
+                assertNotNull(soapBinding);
+                assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
+                assertTrue(WSDLConstants.SOAP12_HTTP_TRANSPORT.
+                           equalsIgnoreCase(soapBinding.getTransportURI()));
+            }
+            
+            BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
+            if (bo == null) {
+                fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
+            }
+            it = bo.getExtensibilityElements().iterator();
+
+            while (it.hasNext()) {
+                Object obj = it.next();
+                assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
+                assertTrue(obj instanceof SOAP12Operation);
+                SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
+                assertNotNull(soapOperation);
+                assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
+            }
+            BindingInput bi = bo.getBindingInput();
+            it = bi.getExtensibilityElements().iterator();
+            while (it.hasNext()) {
+                Object obj = it.next();
+                assertTrue(SOAPBindingUtil.isSOAPBody(obj));
+                assertTrue(obj instanceof SOAP12Body);
+                SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
+                assertNotNull(soapBody);
+                assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
+            }
+        } catch (ToolException e) {
+            fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
+        }
+    }    
+    
+    public void testAddSoap12Binding() throws Exception {
+        String[] args = new String[] {"-i", "Greeter", 
+                                      "-soap12",
+                                      "-b", "Greeter_SOAP12Binding",
+                                      "-d", output.getCanonicalPath(), 
+                                      "-o", "hello_world_soap12_newbinding.wsdl",
+                                      getLocation("/misctools_wsdl/hello_world_soap12.wsdl")};
+        WSDLToSoap.main(args);
+
+        File outputFile = new File(output, "hello_world_soap12_newbinding.wsdl");
+        assertTrue("New wsdl file is not generated", outputFile.exists());
+        
+        WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
+        processor.setEnvironment(env);
+        try {
+            processor.parseWSDL(outputFile.getAbsolutePath());
+            Binding binding = processor.getWSDLDefinition()
+                .getBinding(
+                            new QName(processor.getWSDLDefinition().getTargetNamespace(),
+                                      "Greeter_SOAP12Binding"));
+            if (binding == null) {
+                fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
+            }
+            Iterator it = binding.getExtensibilityElements().iterator();
+
+            while (it.hasNext()) {
+                Object obj = it.next();                
+                assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
+                assertTrue(obj instanceof SOAP12Binding);
+                SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
+                assertNotNull(soapBinding);
+                assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
+    
+            }
+            
+            BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
+            if (bo == null) {
+                fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
+            }
+            it = bo.getExtensibilityElements().iterator();
+
+            while (it.hasNext()) {
+                Object obj = it.next();
+                assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
+                assertTrue(obj instanceof SOAP12Operation);
+                SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
+                assertNotNull(soapOperation);
+                assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
+            }
+            BindingInput bi = bo.getBindingInput();
+            it = bi.getExtensibilityElements().iterator();
+            while (it.hasNext()) {
+                Object obj = it.next();
+                assertTrue(SOAPBindingUtil.isSOAPBody(obj));
+                assertTrue(obj instanceof SOAP12Body);
+                SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
+                assertNotNull(soapBody);
+                assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
+            }
+        } catch (ToolException e) {
+            fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
+        }
+    }    
+
     public void testPartValidation() throws Exception {
         WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
         env.put(ToolConstants.CFG_PORTTYPE, "Greeter");
@@ -210,6 +348,70 @@
                      + "catch other unexpected exception: " + e.getMessage());
             }
         }
+    }
+
+    public void testWithoutBinding() throws Exception {
+        String[] args = new String[] {"-i", "Greeter",                                    
+                                      "-b", "Greeter_SOAPBinding",
+                                      "-d", output.getCanonicalPath(), 
+                                      "-o", "hello_world_soap_newbinding.wsdl",
+                                      getLocation("/misctools_wsdl/hello_world_nobinding.wsdl")};
+        WSDLToSoap.main(args);
+        
+        File outputFile = new File(output, "hello_world_soap_newbinding.wsdl");
+        
+        assertTrue("New wsdl file is not generated", outputFile.exists());
+        assertTrue("Generated file is empty!", outputFile.length() > 0);
+        
+        WSDLToSoapProcessor processor = new WSDLToSoapProcessor();
+        processor.setEnvironment(env);
+        try {
+            processor.parseWSDL(outputFile.getAbsolutePath());
+            Binding binding = processor.getWSDLDefinition()
+                .getBinding(new QName(processor.getWSDLDefinition().getTargetNamespace(), 
+                                      "Greeter_SOAPBinding"));
+            if (binding == null) {
+                fail("Element wsdl:binding Greeter_SOAPBinding_NewBinding Missed!");
+            }
+            Iterator it = binding.getExtensibilityElements().iterator();
+
+            while (it.hasNext()) {
+                Object obj = it.next();                
+                assertTrue(SOAPBindingUtil.isSOAPBinding(obj));
+                assertTrue(obj instanceof SOAPBinding);
+                SoapBinding soapBinding = SOAPBindingUtil.getSoapBinding(obj);
+                assertNotNull(soapBinding);
+                assertTrue("document".equalsIgnoreCase(soapBinding.getStyle()));
+                assertTrue(WSDLConstants.SOAP_HTTP_TRANSPORT.equalsIgnoreCase(soapBinding.getTransportURI()));
+            }
+            
+            BindingOperation bo = binding.getBindingOperation("sayHi", null, null);
+            if (bo == null) {
+                fail("Element <wsdl:operation name=\"sayHi\"> Missed!");
+            }
+            it = bo.getExtensibilityElements().iterator();
+
+            while (it.hasNext()) {
+                Object obj = it.next();
+                assertTrue(SOAPBindingUtil.isSOAPOperation(obj));
+                assertTrue(obj instanceof SOAPOperation);
+                SoapOperation soapOperation = SOAPBindingUtil.getSoapOperation(obj);
+                assertNotNull(soapOperation);
+                assertTrue("document".equalsIgnoreCase(soapOperation.getStyle()));
+            }
+            BindingInput bi = bo.getBindingInput();
+            it = bi.getExtensibilityElements().iterator();
+            while (it.hasNext()) {
+                Object obj = it.next();
+                assertTrue(SOAPBindingUtil.isSOAPBody(obj));
+                assertTrue(obj instanceof SOAPBody);
+                SoapBody soapBody = SOAPBindingUtil.getSoapBody(obj);
+                assertNotNull(soapBody);
+                assertTrue("literal".equalsIgnoreCase(soapBody.getUse()));
+            }
+        } catch (ToolException e) {
+            fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
+        }        
     }
 
     public void testBindingExist() throws Exception {

Added: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl?view=auto&rev=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl (added)
+++ incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl Tue Oct 17 05:40:33 2006
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+		  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+		  xmlns:tns="http://apache.org/hello_world_soap_http"
+		  xmlns:x1="http://apache.org/hello_world_soap_http/types"
+		  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+		  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+		  targetNamespace="http://apache.org/hello_world_soap_http" name="HelloWorld">
+    <wsdl:types>
+	<schema targetNamespace="http://apache.org/hello_world_soap_http/types" 
+		xmlns="http://www.w3.org/2001/XMLSchema" 
+		xmlns:x1="http://apache.org/hello_world_soap_http/types" 
+		elementFormDefault="qualified">
+	    <element name="sayHi">
+		<complexType/>
+	    </element>
+	    <element name="sayHiResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="greetMe">
+		<complexType>
+		    <sequence>
+			<element name="requestType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="greetMeResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="greetMeSometime">
+		<complexType>
+		    <sequence>
+			<element name="requestType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="greetMeSometimeResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="greetMeOneWay">
+		<complexType>
+		    <sequence>
+			<element name="requestType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="testDocLitFault">
+		<complexType>
+		    <sequence>
+			<element name="faultType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="testDocLitFaultResponse">
+		<complexType>
+		    <sequence/>
+		</complexType>
+	    </element>
+	    <complexType name="ErrorCode">
+		<sequence>
+		    <element name="minor" type="short"/>
+		    <element name="major" type="short"/>
+		</sequence>
+	    </complexType>
+	    <element name="NoSuchCodeLit">
+		<complexType>
+		    <sequence>
+			<element name="code" type="x1:ErrorCode"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="BadRecordLit" type="string"/>
+	    <complexType name="BadRecord">
+		<sequence>
+		    <element name="reason" type="string"/>
+		    <element name="code" type="short"/>
+		</sequence>
+	    </complexType>
+	    <complexType name="addNumbers">
+		<sequence>
+		    <element name="arg0" type="int"/>
+		    <element name="arg1" type="int"/>
+		</sequence>
+	    </complexType>
+	    <element name="addNumbers" type="x1:addNumbers"/>
+	    <complexType name="addNumbersResponse">
+		<sequence>
+		    <element name="return" type="int"/>
+		</sequence>
+	    </complexType>
+	    <element name="addNumbersResponse" type="x1:addNumbersResponse"/>
+	    <element name="BareDocument" type="string"/>
+	    <element name="BareDocumentResponse">
+		<complexType>
+		    <sequence>
+			<element name="company" type="string"/>
+		    </sequence>
+		    <attribute name="id" type="int"/>
+		</complexType>
+	    </element>      
+	</schema>
+    </wsdl:types>
+    <wsdl:message name="sayHiRequest">
+	<wsdl:part name="in" element="x1:sayHi"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+	<wsdl:part name="out" element="x1:sayHiResponse"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeRequest">
+	<wsdl:part name="in" element="x1:greetMe"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeResponse">
+	<wsdl:part name="out" element="x1:greetMeResponse"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeSometimeRequest">
+	<wsdl:part name="in" element="x1:greetMeSometime"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeSometimeResponse">
+	<wsdl:part name="out" element="x1:greetMeSometimeResponse"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeOneWayRequest">
+	<wsdl:part name="in" element="x1:greetMeOneWay"/>
+    </wsdl:message>
+    <wsdl:message name="testDocLitFaultRequest">
+	<wsdl:part name="in" element="x1:testDocLitFault"/>
+    </wsdl:message>
+    <wsdl:message name="testDocLitFaultResponse">
+	<wsdl:part name="out" element="x1:testDocLitFaultResponse"/>
+    </wsdl:message>
+    <wsdl:message name="NoSuchCodeLitFault">
+	<wsdl:part name="NoSuchCodeLit" element="x1:NoSuchCodeLit"/>
+    </wsdl:message>
+    <wsdl:message name="BadRecordLitFault">
+	<wsdl:part name="BadRecordLit" element="x1:BadRecordLit"/>
+    </wsdl:message>
+    <wsdl:message name="testDocLitBareRequest">
+	<wsdl:part name="in" element="x1:BareDocument"/>
+    </wsdl:message>
+    <wsdl:message name="testDocLitBareResponse">
+	<wsdl:part name="out" element="x1:BareDocumentResponse"/>
+    </wsdl:message> 
+    <wsdl:portType name="Greeter">
+	<wsdl:operation name="sayHi">
+	    <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+	    <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+	</wsdl:operation>
+	<wsdl:operation name="greetMe">
+	    <wsdl:input name="greetMeRequest" message="tns:greetMeRequest"/>
+	    <wsdl:output name="greetMeResponse" message="tns:greetMeResponse"/>
+	</wsdl:operation>
+	<wsdl:operation name="greetMeSometime">
+	    <wsdl:input name="greetMeSometimeRequest" message="tns:greetMeSometimeRequest"/>
+	    <wsdl:output name="greetMeSometimeResponse" message="tns:greetMeSometimeResponse"/>
+	</wsdl:operation>
+	<wsdl:operation name="greetMeOneWay">
+	    <wsdl:input name="greetMeOneWayRequest" message="tns:greetMeOneWayRequest"/>
+	</wsdl:operation>
+	<wsdl:operation name="testDocLitFault">
+	    <wsdl:input name="testDocLitFaultRequest" message="tns:testDocLitFaultRequest"/>
+	    <wsdl:output name="testDocLitFaultResponse" message="tns:testDocLitFaultResponse"/>
+	    <wsdl:fault name="NoSuchCodeLitFault" message="tns:NoSuchCodeLitFault"/>
+	    <wsdl:fault name="BadRecordLitFault" message="tns:BadRecordLitFault"/>
+	</wsdl:operation>
+	<wsdl:operation name="testDocLitBare">
+	    <wsdl:input name="testDocLitBareRequest" message="tns:testDocLitBareRequest"/>
+	    <wsdl:output name="testDocLitBareResponse" message="tns:testDocLitBareResponse"/>
+	</wsdl:operation>       
+    </wsdl:portType>
+</wsdl:definitions>
+

Propchange: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_nobinding.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl?view=auto&rev=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl (added)
+++ incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl Tue Oct 17 05:40:33 2006
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<definitions name="HelloWorld"
+	     xmlns="http://schemas.xmlsoap.org/wsdl/"
+	     xmlns:tns="http://apache.org/hello_world_soap12_http"
+	     xmlns:x1="http://apache.org/hello_world_soap12_http/types"
+	     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	     targetNamespace="http://apache.org/hello_world_soap12_http"
+	     xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
+    <wsdl:types>
+	<schema targetNamespace="http://apache.org/hello_world_soap12_http/types" 
+		xmlns="http://www.w3.org/2001/XMLSchema" 
+		xmlns:x1="http://apache.org/hello_world_soap12_http/types" 
+		elementFormDefault="qualified">
+	    <element name="sayHi">
+		<complexType/>
+	    </element>
+	    <element name="sayHiResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+        </schema>
+    </wsdl:types>
+
+    <wsdl:message name="sayHiRequest">
+        <wsdl:part name="in" element="x1:sayHi"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+        <wsdl:part name="out" element="x1:sayHiResponse"/>
+    </wsdl:message>
+
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="sayHi">
+            <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+            <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+        </wsdl:operation>
+    </wsdl:portType>
+
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+	<soap12:binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/" style="document" />
+	<operation name="sayHi">
+	    <soap12:operation style="document" soapAction=""/>
+	    <input>
+		<soap12:body use="literal" />
+	    </input>
+	    <output>
+		<soap12:body use="literal" />
+	    </output>
+	</operation>
+    </wsdl:binding>
+
+
+</definitions>

Propchange: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12_nobinding.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12_nobinding.wsdl?view=auto&rev=464917
==============================================================================
--- incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12_nobinding.wsdl (added)
+++ incubator/cxf/trunk/tools/misctools/src/test/resources/misctools_wsdl/hello_world_soap12_nobinding.wsdl Tue Oct 17 05:40:33 2006
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<definitions name="HelloWorld"
+	     xmlns="http://schemas.xmlsoap.org/wsdl/"
+	     xmlns:tns="http://apache.org/hello_world_soap12_http"
+	     xmlns:x1="http://apache.org/hello_world_soap12_http/types"
+	     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	     targetNamespace="http://apache.org/hello_world_soap12_http"
+	     >
+    <wsdl:types>
+	<schema targetNamespace="http://apache.org/hello_world_soap12_http/types" 
+		xmlns="http://www.w3.org/2001/XMLSchema" 
+		xmlns:x1="http://apache.org/hello_world_soap12_http/types" 
+		elementFormDefault="qualified">
+	    <element name="sayHi">
+		<complexType/>
+	    </element>
+	    <element name="sayHiResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	</schema>
+    </wsdl:types>
+
+    <wsdl:message name="sayHiRequest">
+	<wsdl:part name="in" element="x1:sayHi"/>
+    </wsdl:message>
+    <wsdl:message name="sayHiResponse">
+	<wsdl:part name="out" element="x1:sayHiResponse"/>
+    </wsdl:message>
+
+    <wsdl:portType name="Greeter">
+	<wsdl:operation name="sayHi">
+	    <wsdl:input name="sayHiRequest" message="tns:sayHiRequest"/>
+	    <wsdl:output name="sayHiResponse" message="tns:sayHiResponse"/>
+	</wsdl:operation>
+    </wsdl:portType>
+
+</definitions>



Mime
View raw message