You use the tool in the following three stages:
Note: You can perform stage 1 several times to create related Web services in the same project directory. In stage 3, you can then create a separate module for each of these Web services and add these modules to the same EAR file.
Before using the WSDL2WebService tool, you must set up the Web services command line as follows:
Now, you can run stage 1 of the WSDL2WebService tool.
To create a skeleton Web service implementation, enter the following in the command prompt:
Note: The final argument must be <WSDL URI>, which is case-sensitive. See The WSDL2WebService tool for a list of optional and mandatory arguments.
After you have run the tool with the -createService <ServiceName> argument, a directory named <ServiceName> containing several subdirectories is created under the specified project. These subdirectories contain all the necessary Java templates that are required to build the Web service implementation.
This is an example of how to use the WSDL2WebService tool:
WSDL2WebService -createService ejb1Service -project dir:\myproj\ejbDir -host localhost:9080 -contextRoot ejb1Service -type EJB -verbose dir:\TempConv.wsdl
You need to modify the skeleton Java files so that they correctly implement the Web service you are creating. Once you have added the correct code to the Java skeletons they need to be compiled. A build script called compile is also generated to help you compile all this code.
To compile the implementation code:
Once you have created the service, added the implementation code to the Java skeletons, and compiled the new code, you need to create a Web services enabled archive To create a Web-services enabled archive, enter the following in the command prompt:
See The WSDL2WebService tool for an explanation of optional and mandatory arguments.
Hint: Note the command line test directory path and the name that you specify for -project if you want to deploy and test your Web service.
After you have written the implementation code, compiled it, and run the tool again with the -createEar <File.ear> argument, the output will be either a new or updated EAR file. This will contain a Web service module for each of the Web service names specified with the -add argument. You will also notice that the server-side classes that implement the Web service have been moved to the WEB-INF\classes directory, which is the normal location. If you do not specify the -server-side-only argument, a client-side directory that contains some extra Java files, including serializer and deserializer classes for your complex types, is also created.
Once you have generated an EAR file, you can deploy it to a server to make it available to others. To do this, refer to: Deploying a Web service to a server using the command line tools.
WSDL2WebService -createEAR dir:\myear\ejb1ear.ear -project dir:\myproj\ejbDir -add ejb1Service -verbose localhost:9080/ejb1Service/services/TempConv
WSDL2WebService -createEar dir:\myear\ejb1ear.ear -rootModule ejb1Service/services/Service -host localhost:9080 -project dir:\myproj\MultiServiceThis will create MultiServiceEAR.ear containing a single module called Service_WEB.war with the merged Web services. The module's context root is Service_WEB. The host name and port number in all service endpoints in the WSDL files will be changed to localhost:9080.
The WSDL2WebService tool supports the reuse of code by allowing you to place JAR or EJB files (which are accessed by one or more of the contained Web services) in the root of an EAR file. You can reuse a Web services implementation by archiving all the classes into a JAR file of the same name as the service. Do the following steps to archive the classes into a JAR file: