Creating a web service from a Java bean using the IBM WebSphere JAX-RPC runtime environment

The web service wizard assists you in creating a new web service, configuring it for deployment, and deploying the web service to a server. Once your web service is deployed, the wizard assists you in generating the client proxy and sample application to test the web service. When you have completed testing, you can publish your web service to a UDDI Business Registry using the Export wizard.

Before you begin

Prerequisites:

About this task

To create a web service from a bean using the IBM® WebSphere JAX-RPC runtime environment:

Procedure

  1. Switch to the Java EE perspective (Window > Open Perspective > Java EE).
  2. In the Enterprise Explorer view, select the bean that you created or imported into the source folder of your Web project.
  3. Click File > New > Other. Select Web Services in order to display the various Web service wizards. Select the Web Service wizard. Click Next.
  4. Web Services page: select Bottom up Java bean Web service as your web service type. You can optionally choose to do the following:
    1. Select the stages of web services development that you want to complete using the slider. This will set several default values on the remaining wizard panels.
      • Develop: this will develop the WSDL definition and implementation of the web service. This includes such tasks as creating the modules which will contain the generated code, WSDL files, deployment descriptors, and Java files when appropriate.
      • Assemble: this ensures the project that will host the web service or client gets associated to an EAR when required by the target application server.
      • Deploy: this will create the deployment code for the service.
      • Install: this will install and configure the Web module and EARs on the target server. If any changes to the endpoints of the WSDL file are required they will be made in this stage.
      • Start: this will start the server once the service has been installed on it.
      • Test: this will provide various options for testing the service, such as using the Generic Services Client, Web Service Explorer or sample JSPs.
    2. Select your server: the default server is displayed. If you want to deploy your service to a different server click the link to specify a different server.
    3. Select your runtime: the default runtime is displayed. If you want to deploy your service to a different runtime click the link to specify a different runtime.
    4. Select the service project: the project selected in your workspace is displayed. To select a different project and EAR click on the project link. Ensure that the project selected as the Client Web Project is different from the Service Web Project, or the service will be overwritten by the client's generated artifacts.
    5. If you want to create a client, select the type of proxy to be generated and repeat the above steps for the client.
    6. Publish the web service: this launches the Web Services Explorer to publish your web service to a UDDI registry.
    7. Monitor the web service: this will send the web service traffic through the TCP/IP Monitor, which allows you to watch the SOAP traffic generated by the web service and to test this traffic for WS-I compliance. Alternately you can manually set up a TCP/IP monitor as described in Using the TCP/IP Monitor to test web services Note that if you are routing web service traffic through the TCP/IP monitor that you cannot test the web service using the Universal Test Client.
  5. Service Endpoint Interface Selection page:
    • You can select to use an existing service endpoint interface (SEI) rather than letting the wizard generate one.
    • Set the service deploy scope. This indicates how to deploy the server implementation. Application uses one instance of the implementation class for all requests. Request creates a new instance of the implementation class for each request. Session creates a new instance of the implementation class for each session.
    • Set the SOAP action. This option is used to set the soapAction field in the generated WSDL. Default sets the soapAction field according to the deployment information. None sets the soapAction field to double quotes (""). Operation sets the soapAction field to the operation name.
    • You can also choose to exclusively map MIME types using WSDL 1.1 standards. If the MIME type cannot map to WSDL 1.1 standards (for example, if the attachment is an array or a Java bean property), the command fails.
  6. Web Service Java Bean Identity page:
    • Change the WSDL port name if required.
    • Change the WSDL file name or path if required. Any path information you provide in this field will create folders within the WEB-INF/wsdl folder. This can be useful if you do not want to overwrite WSDL or XSD files already in the default folder.
    • Select the methods to expose.
    • Set the void return - this field is for a web service method with return type of void that describes whether a response is expected from the web service. Oneway: this argument is the default for a JMS transport. Twoway: this argument is the default for an HTTP transport.
    • Select the encoding style. This specifies which style and use combinations are generated into the WSDL file. The combinations are RPC/encoded, RPC/literal, or document/literal. Only document/literal is WS-I compliant.
    • Select your security options. Security is not WS-I compliant.
    • Select if you want to customize the package to namespace mappings.
    • Specify extra and stop classes. Extra specifies other classes that are represented in the WSDL file. You can use the -stopClasses argument to define additional classes that cause the search to stop.
  7. Web Service Package to Namespace Mappings page: The Web services wizard generates a WSDL file from the specified Java bean. By default it will create a namespace based on the package name of the Java bean. To override this default behavior you can specify your own namespaces to be generated in the WSDL file. If you selected Define custom mapping for package to namespace on the previous page, you can enter your custom mapping pairs on this page by clicking Add. Alternately, you can click Import to import custom mapping pairs from a .properties file. The content of the properties file must be of the format package=namespace. You will need to escape some special characters in the properties files. For example somePackage=http://someNamespace should be somePackage=http\://someNamespace. Otherwise, the colon (:) would be treated as delimiter resulting in trying to map somepackage to http. For more information about formats for properties files in Java, refer to: Java Platform API documentation: java.util.Properties load method.
  8. Extra and Stop Classes Configuration page: if you selected Specify extra and stop classes you can import your extra and stop classes on this page. Extra specifies other classes that are represented in the WSDL file. You can use the -stopClasses argument to define additional classes that cause the search to stop.
  9. Web Service Test page: If you selected to test the web service, select the test facility for the generated web service. This will open the web service in the Web Services Explorer or Generic Services Client. Select the operation you want to test, enter the required information, and click Go. The result will display in the Status pane. Click Next.
  10. Web Service Proxy page: if you have selected to generate a proxy, select the proxy security options and select if you want to customize the package to namespace mappings.
  11. Web Service Client Namespace to Package Mappings page: if you selected Define custom mapping for namespace to package on the previous page, you can enter your custom mapping pairs on this page by clicking Add. Alternately, you can click Import to import custom mapping pairs from a .properties file. The content of the properties file must be of the format namespace=package. You will need to escape some special characters in the properties files. For example http://someNamespace=somePackage should be http\://someNamespace=somePackage. Otherwise, the colon (:) would be treated as delimiter resulting in trying to map http to //someNamespace=somePackage. For more information about formats for properties files in Java, refer to: Java Platform API documentation: java.util.Properties load method.
  12. Web Service Client Test page:
    • Select your test facility. You can test the generated proxy in the Universal Test Client or the web service Explorer, or you can generate a sample web service JSP. Note that if you are routing web service traffic through the TCP/IP monitor that you cannot test the web service using the Universal Test Client.
    • If you selected to test the proxy through a JSP, you can select the folder where the JSP will be located, and you can select the methods that will be included in the JSP.
    • Select Run test on server to start the server for you automatically.
  13. Web Service Publication page: Select whether or not you want to publish this web service to a UDDI registry. Click Finish.

Results

After the web service has been created, the following may occur depending on the options you selected:

Example

For useful tips when creating a JAX-RPC Web service from a Java bean, refer to the following article available at developerWorks®: IBM Rational® Application Developer Web Services Tooling Tips and Tricks: Part 2: Validate Java classes for compliance to JAX-RPC

Feedback