Example: Developing Web services based on Web Services for J2EE

This example takes you through the steps to develop a Web service from an enterprise JavaBean (EJB) implementation. The development process is based on the Web Services for J2EE specification.

  1. Select the EJB or Java bean implementation that you want to enable as a Web service.

    The implementation must meet the following Web Services for J2EE specification requirements...

    • It must have methods that can be mapped to a Service Endpoint Interface. See step 2 for more information.

    • It must be a stateless session EJB or a Java bean without client-specific state, since the implementation bean might be selected to process a request from any client. If a client-specific state is required, a client identifier must be passed as a parameter of the Web service operation.

      The selected methods of an EJB must not have a transaction attribute of Mandatory, because there is no standard for Web services transactions at this time.

      A Java bean in a Web container requires the following...

      • A public default constructor

      • Exposed public methods

      • It must not save a client-specific state between method calls

      • It must be a public, non-final, and non-abstract class

      • It must not define a finalize() method

  2. Develop a Service Endpoint Interface.

    Developing a Web service requires a Service Endpoint Interface.

    If you are using an EJB implementation, develop a Service Endpoint Interface from an EJB remote interface.

    If you are using a Java bean implementation, develop a Service Endpoint Interface for a Java bean implementation.

  3. Develop a WSDL file.

  4. Develop deployment descriptor templates.

    If you are using an EJB implementation, develop Web services deployment descriptor templates from an EJB implementation.

    If you are using a Java bean implementation, develop Web services deployment descriptor templates for a Java bean implementation.

  5. Configure the deployment descriptors.

    By setting the ejb-link or servlet-link values of the service-impl-bean elements you can link to the EJB or Java bean that implements the service.

    Configure the webservices.xml deployment descriptor.

    Configure the ibm-webservices-bnd.xmi deployment descriptor.

  6. Assemble a JAR file or Assemble a WAR file.

  7. Assemble an EAR file from a Jar file or Assemble an EAR file from a WAR file.

  8. Enable the Web service-enabled EAR file.

    This step only applies if you are using an EJB implementation.

  9. Deploy the Web service application.

  10. Publish the WSDL file.

 

See Also

Developing Web services based on Web Services for J2EE