+

Search Tips   |   Advanced Search

Implement web services applications with JAX-WS

When starting from existing JavaBeans or enterprise beans, we can use a bottom-up approach to developing Web services based on the JAX-WS programming model.

To develop web services based on the JAX-WS programming model, we can use a bottom-up development approach starting from existing JavaBeans or enterprise beans or we can use a top-down development approach starting with an existing WSDL file. This task describes the steps when using the bottom-up development approach.

When developing JAX-WS web services starting from existing JavaBeans or enterprise beans, we can expose the bean as a JAX-WS web service by using annotations. Adding the @WebService or @WebServiceProvider annotation to the bean defines the bean as a JAX-WS web service. JAX-WS web services can optionally use a service endpoint interface. In addition to annotating the bean and the optional service endpoint interface, you must assemble all the artifacts that the web service requires, and deploy the resulting application into the application server environment to complete the process of enabling the bean as a web service. Although the use of a WSDL file is considered a best practice, you are not required to package a WSDL file with the JAX-WS web services.

Considerations when using JavaBeans

  • JavaBeans exposed as JAX-WS web services are supported only over an HTTP transport.

  • JavaBeans may use Contexts and Dependency Injection (CDI). Note that constructor injection is not supported.

Considerations when using enterprise beans

Starting with WAS v7 and later, Java EE 5 application modules (web application modules version 2.5 or above, or EJB modules version 3.0 or above) are scanned for annotations to identify JAX-WS services and clients. However, pre-Java EE 5 application modules (web application modules version 2.4 or before, or EJB modules version 2.1 or before) are not scanned for JAX-WS annotations, by default, for performance considerations. In the Version 6.1 Feature Pack for Web Services, the default behavior is to scan pre-Java EE 5 web application modules to identify JAX-WS services and to scan pre-Java EE 5 web application modules and EJB modules for service clients during application installation. Because the default behavior for WAS v7 and later is to not scan pre-Java EE 5 modules for annotations during application installation or server startup, to preserve backward compatability with the feature pack from previous releases, configure either the UseWSFEP61ScanPolicy property in the META-INF/MANIFEST.MF of a WAR file or EJB module or define the JVM custom property, com.ibm.websphere.webservices.UseWSFEP61ScanPolicy, on servers to request scanning during application installation and server startup. To learn more about annotations scanning, see the JAX-WS annotations information.

  1. Set up a development environment for web services.

  2. Determine the existing JavaBeans or enterprise beans to expose as a JAX-WS web service.

  3. Develop JAX-WS web services with annotations.

  4. Generate Java artifacts for JAX-WS applications.

  5. (Optional) Enable MTOM for JAX-WS web services.

  6. (Optional) Enforce adherence to WSDL bindings in JAX-WS web services.

  7. (Optional) Develop and configure a webservices.xml deployment descriptor for JAX-WS applications.

  8. Complete the implementation of the web services application.

  9. (Optional) Customize URL patterns in web.xml.

  10. Assemble the artifacts for the web service.

  11. Deploy the EAR file into the application server.

  12. Test the web service to verify the service works with the application server.


Results

You have developed a JAX-WS application.


Subtopics


Related concepts

  • JAX-WS
  • Web services


    Related tasks

  • Enforcing adherence to WSDL bindings in JAX-WS web services
  • Assembling web services applications
  • Deploy web services applications onto application servers
  • Test web services-enabled clients
  • Use HTTP to transport web services
  • Use SOAP over JMS to transport web services
  • Example: Install a web services sample with the console
  • Implement web services applications from existing WSDL files with JAX-WS

  • Artifacts used to develop web services
  • JAX-WS annotations
  • Web services specifications and APIs
  • Contexts and Dependency Injection (CDI)


    Related information:

    JAX-WS API documentation
    JAX-WS API User's Guide documentation