Author: dims Date: Sat Jun 2 20:45:17 2007 New Revision: 543838 URL: http://svn.apache.org/viewvc?view=rev&rev=543838 Log: Voila! world's first command line tool to generate a WSDL 2.0 document from a java class :)
Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLOptionsValidator.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/Java2WSDLConstants.java Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java?view=diff&rev=543838&r1=543837&r2=543838 ============================================================================== --- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java (original) +++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLBuilder.java Sat Jun 2 20:45:17 2007 @@ -9,6 +9,7 @@ import org.apache.axis2.description.WSDL2Constants; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.AxisService2WSDL11; +import org.apache.axis2.description.AxisService2WSDL20; import org.apache.axis2.util.Loader; import org.apache.axis2.engine.MessageReceiver; import org.apache.axis2.context.ConfigurationContextFactory; @@ -64,6 +65,7 @@ private String nsGenClassName = null; private Map pkg2nsMap = null; private boolean pretty = true; + private String wsdlVersion = WSDL_VERSION_1; public String getSchemaTargetNamespace() throws Exception { if ( schemaTargetNamespace == null ) { @@ -214,16 +216,24 @@ axisService.setEPRs(new String[]{uri}); configCtx.getAxisConfiguration().addService(axisService); - //TODO: Switch for WSDL20 - - AxisService2WSDL11 g = new AxisService2WSDL11(axisService); - g.setStyle(this.style); - g.setUse(this.use); - OMElement wsdlElement = g.generateOM(); - if(!isPretty()){ - wsdlElement.serialize(out); + if (WSDL_VERSION_1.equals(wsdlVersion)) { + AxisService2WSDL11 g = new AxisService2WSDL11(axisService); + g.setStyle(this.style); + g.setUse(this.use); + OMElement wsdlElement = g.generateOM(); + if(!isPretty()){ + wsdlElement.serialize(out); + } else { + Java2WSDLUtils.prettyPrint(wsdlElement, out); + } } else { - Java2WSDLUtils.prettyPrint(wsdlElement, out); + AxisService2WSDL20 g = new AxisService2WSDL20(axisService); + OMElement wsdlElement = g.generateOM(); + if(!isPretty()){ + wsdlElement.serialize(out); + } else { + Java2WSDLUtils.prettyPrint(wsdlElement, out); + } } out.flush(); @@ -290,6 +300,10 @@ public void setPretty(boolean pretty) { this.pretty = pretty; + } + + public void setWSDLVersion(String wsdlVersion) { + this.wsdlVersion = wsdlVersion; } } Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java?view=diff&rev=543838&r1=543837&r2=543838 ============================================================================== --- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java (original) +++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/Java2WSDLCodegenEngine.java Sat Jun 2 20:45:17 2007 @@ -196,6 +196,18 @@ option = loadOption(Java2WSDLConstants.JAVA_PKG_2_NSMAP_OPTION, Java2WSDLConstants.JAVA_PKG_2_NSMAP_OPTION_LONG, optionsMap); java2WsdlBuilder.setPkg2nsMap(loadJavaPkg2NamespaceMap(option)); + + option = loadOption(Java2WSDLConstants.WSDL_VERSION_OPTION, + Java2WSDLConstants.WSDL_VERSION_OPTION_LONG, + optionsMap); + if (option != null) { + String optionValue = option.getOptionValue(); + if (Java2WSDLConstants.WSDL_VERSION_2.equals(optionValue) || + Java2WSDLConstants.WSDL_VERSION_2_OPTIONAL.equals(optionValue)) { + //users can say either 2.0 or 2 - we just set it to the constant + java2WsdlBuilder.setWSDLVersion(Java2WSDLConstants.WSDL_VERSION_2); + } //ignore the other cases - they'll be taken as 1.1 + } } /** Modified: webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLOptionsValidator.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLOptionsValidator.java?view=diff&rev=543838&r1=543837&r2=543838 ============================================================================== --- webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLOptionsValidator.java (original) +++ webservices/axis2/trunk/java/modules/java2wsdl/src/org/apache/ws/java2wsdl/utils/Java2WSDLOptionsValidator.java Sat Jun 2 20:45:17 2007 @@ -59,6 +59,8 @@ Java2WSDLConstants.SERVICE_NAME_OPTION_LONG.equalsIgnoreCase(optionType)|| Java2WSDLConstants.STYLE_OPTION_LONG.equalsIgnoreCase(optionType)|| Java2WSDLConstants.USE_OPTION_LONG.equalsIgnoreCase(optionType)|| + Java2WSDLConstants.WSDL_VERSION_OPTION.equalsIgnoreCase(optionType)|| + Java2WSDLConstants.WSDL_VERSION_OPTION_LONG.equalsIgnoreCase(optionType)|| Java2WSDLConstants.LOCATION_OPTION_LONG.equalsIgnoreCase(optionType)); Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/Java2WSDLConstants.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/Java2WSDLConstants.java?view=diff&rev=543838&r1=543837&r2=543838 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/Java2WSDLConstants.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/java2wsdl/Java2WSDLConstants.java Sat Jun 2 20:45:17 2007 @@ -105,6 +105,7 @@ String EXTRA_CLASSES_DEFAULT_OPTION = "xc"; String NAMESPACE_GENERATOR_OPTION = "nsg"; String JAVA_PKG_2_NSMAP_OPTION = "p2n"; + String WSDL_VERSION_OPTION = "wv"; //long option constants String OUTPUT_LOCATION_OPTION_LONG = "output"; @@ -125,7 +126,11 @@ String EXTRA_CLASSES_DEFAULT_OPTION_LONG = "extraClasses"; String NAMESPACE_GENERATOR_OPTION_LONG = "namespaceGenerator"; String JAVA_PKG_2_NSMAP_OPTION_LONG = "package2Namespace"; + String WSDL_VERSION_OPTION_LONG = "wsdl-version"; public static final String SOLE_INPUT = "SOLE_INPUT"; + String WSDL_VERSION_2 = "2.0"; + String WSDL_VERSION_2_OPTIONAL = "2"; + String WSDL_VERSION_1 = "1.1"; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]