Develop EJB implementation templates and bindings from a WSDL file for JAX-RPC web services
We can develop EJB implementation deployment descriptor templates and bindings from a WSDL file for a JAX-RPC application.
To develop EJB implementation templates and bindings from a WSDL file for a JAX-RPC web service, we must obtain the URL of the WSDL file to use.
(Windows) (ZOS) If the WSDL file is a local file, the URL looks like the following example: file:drive:\path\file_name.wsdl.
(Linux) (AIX) (HPUX) (Solaris) (iSeries) If the WSDL file is a local file, the URL looks like the following example: file:/path/file_name.wsdl.
We can also specify local files using the absolute or relative file system path.
This task is one a required step in developing a web service from an enterprise bean.
Implementation templates are generated using the -role develop-server option of the WSDL2Java command.
Templates are generated for an EJB implementation for the following components:
- enterprise bean
- EJB remote interface
- EJB Home
The WSDL2Java command also generates bindings and deployment descriptors.
(ZOS) The WSDL2Java command-line tool is not supported on the z/OS platform. This functionality is provided by the assembly tools provided with the z/OS version of the product. Read about the WSDL2Java command-line tool for Java API for XML-based Remote Procedure Call (JAX-RPC) applications to learn more about this tool.
It is a best practice to use absolute namespaces within the WSDL or schema. By default, the WSDL2Java tool does not permit the use of relative namespaces. Relative namespaces have been deprecated by the XML Plenary Interest Group and the use of relative namespaces causes the XML Digital Signature to fail as required by the Canonical XML Version 1.0 specification. We can convert any relative namespaces to absolute namespaces. To learn more about the use of namespaces with the WSDL2Java tool, see the WSDL2Java command for JAX-RPC applications documentation. bprac
Tasks
Run the WSDL2Java -verbose -role develop-server -container ejb wsdlURL command. Because the verbose option is specified, a list of all the generated files is displayed when the command runs.
We have templates for the implementation and deployment descriptors required to implement web services, as well as bindings files. These templates are partially completed with information from the WSDL file.
Example
The following example uses the enterprise bean AddressBook enterprise bean and the AddressBook.wsdl file. After generating the template files from the WSDL2Java -verbose -role develop-server -container EJB AddressBook.wsdl command, the following files are generated:Parsing XML file: file:e:/example/app/topdown/step1/AddressBook.wsdl WSWS3185I: Info: Parsing XML file: AddressBook.wsdl WSWS3282I: Info: Generating addr\Address.java. WSWS3282I: Info: Generating addr\Phone.java. WSWS3282I: Info: Generating addr\StateType.java. WSWS3282I: Info: Generating addr\AddressBook.java. WSWS3282I: Info: Generating addr\AddressBookSoapBindingImpl.java. WSWS3282I: Info: Generating addr\AddressBook_RI.java. WSWS3282I: Info: Generating addr\AddressBookHome.java. WSWS3282I: Info: Generating META-INF\webservices.xml. WSWS3282I: Info: Generating META-INF\ibm-webservices-bnd.xmi. WSWS3282I: Info: Generating META-INF\AddressBook_mapping.xml. WSWS3282I: Info: Generating META-INF\ibm-webservices-ext.xmi.
What to do next
Complete the EJB implementation. When completing the EJB implementation, an EJB Java archive (JAR) file containing an EJB and supporting classes is created from a WSDL file.
Related:
Development and assembly tools Implement web services applications with JAX-RPC Implement web services applications from existing WSDL files with JAX-RPC Completing the EJB implementation for JAX-RPC applications WSDL2Java command for JAX-RPC applications