WSDL2Java Service is a Utility Web service that offers SOAP access to the WSDL2Java tool, which generates Java source files from WSDL. The WSDL can be specified by a URL or a SOAP Attachment. The WSDL2Java Service output is usually a set of Java interface files packed in a JAR file.
The WSDL2Java Service is installed in the WSDLCompiler-US component. There is an Admin Console interface for the service, which is installed in Console-WSDLCompiler-US.
![]() | Note |
---|---|
WSDL2Java and the WSDL2Java Service were previously named WSDLCompiler. Endpoints, WSO2 SOA Enablement Server components and the API for the WSDL2Java Service still refer to WSDLCompiler for the sake of backward compatibility. |
The WSDL2Java Service API has two methods:
executeAttach()
Compiles a WSDL sent as a SOAP Attachment
executeUrl()
Compiles a WSDL specified by URL
For more details, see the API documentation for org.systinet.wasp.management.services.wsdlc.WSDLCompilerService
Example 288 shows a code sample where a WSDL is compiled from a WSDL specified by URL. The compiled output is output.jar.
Example 288. Using the executeUrl() Method of the WSDL2Java Service
// Copyright WSO2 Inc. All rights reserved. // Use is subject to license terms. package example.utilservices.wsdlcompiler; import org.systinet.wasp.management.services.wsdlc.CompilerSettings; import org.systinet.wasp.management.services.wsdlc.WSDLCompilerService; import org.systinet.wasp.webservice.Registry; import org.idoox.wasp.tools.wsdlc.WSDLCompiler; import org.idoox.wasp.types.MessageAttachment; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; public class WSDLCServiceExample { public static void main(String[] args) throws Exception { WSDLCompilerService compiler = (WSDLCompilerService) Registry.lookup( "http://localhost:6060/util/WSDLCompilerService", WSDLCompilerService.class); // compiler settings CompilerSettings settings = new CompilerSettings(); settings.generateAllTypes = false; settings.iFacePackageName = "demo.mypackage"; settings.outputBackends = "java"; settings.typesGeneratingMode = WSDLCompiler.MODE_TYPES_AS_INTERFACES; // call WSDL2Java Service MessageAttachment jarAttach = new MessageAttachment(); compiler.executeUrl( "http://localhost:6060/PingService/", jarAttach, settings); // save output jar InputStream is = jarAttach.getData(); byte[] buffer = new byte[1024]; FileOutputStream outputStream = new FileOutputStream(new File("output.jar")); int count; while ((count = is.read(buffer, 0, 1024)) > 0) { outputStream.write(buffer, 0, count); } } }
WSDL2Java Service settings are stored in the org.systinet.wasp.management.services.wsdlc.CompilerSettings class. It has these options:
generateAllTypes
A Boolean type. If set to true, the compiler will generate all the types mentioned in the schema section of the WSDL, not only the referenced ones.
iFacePackageName
A string. The name of the package into which interfaces are generated.
outputBackends
A string. Sets the output back-end listed in the configuration, usually either java or java-async.
typesGeneratingMode
An int type. Sets the generation mode for types. WSDL2Java can generate the following (with the Constant name in parentheses):
Interfaces (MODE_TYPES_AS_INTERFACES)
Structures (MODE_TYPES_AS_STRUCTURES)
JavaBeans (MODE_TYPES_AS_JAVABEANS)
For more information on these data types, please see WSDL2Java.