Implement web services applications from existing WSDL files with JAX-WS
When starting with an existing Web Services Description Language (WSDL) file, we can use a top-down approach to developing web services based on JAX-WS.
IBM WebSphere Application Server supports JAX-WS and JAX-RPC. JAX-WS is the next generation web services programming model extending the foundation provided by JAX-RPC. Using the strategic JAX-WS programming model, development of web services and clients is simplified through support of a standards-based annotations model. Although JAX-RPC and applications are still supported, take advantage of the easy-to-implement JAX-WS programming model to develop new web services applications and clients.best-practices
Locate the WSDL file that defines the web service to implement. We can develop a WSDL file or obtain one from an existing web service through email, downloading or a URL.
To develop web services based on JAX-WS, 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 top-down development approach.
- 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
- The enterprise bean must be a stateless or singleton session bean.
- Enterprise beans exposed as JAX-WS web services must be packaged in EJB 3.0 or higher modules.
- JAX-WS web service applications containing enterprise beans must be deployed with the endptEnabler command.
- JAX-WS web services using enterprise beans are supported over an HTTP or JMS transport.
- Enterprise beans may use CDI. Note that constructor injection is not supported.
- Set up a development environment for web services. We do not have to set up a development environment if we are using Rational Application Developer.
- Develop Java artifacts for JAX-WS applications using the wsimport command-line tool. The wsimport tool processes a WSDL file and generates portable Java artifacts used to create a web service.
- (optional) Enable MTOM for JAX-WS web services. Use SOAP Message Transmission Optimization Mechanism to optimize the transmission of binary attachments such as images or files along with web services requests.
- (optional) Enforce adherence to WSDL bindings in JAX-WS web services. Use the RespectBindingFeature to control whether a JAX-WS implementation is required to respect the contents of a wsdl:binding associated with an endpoint.
- (optional) Develop and configure a webservices.xml deployment descriptor for JAX-WS applications. We can optionally use the webservices.xml deployment descriptor to augment or override application metadata specified in annotations within your JAX-WS web services.
- Complete the implementation of our web service application.
- For JavaBeans applications, complete the JavaBeans implementation.
- For enterprise beans applications, complete the enterprise beans implementation.
- (Optional) Customize URL patterns in the web.xml file. When JavaBeans are exposed as JAX-WS endpoints, we can optionally customize the URL patterns within the web.xml deployment descriptor contained in the web application archive (WAR) file.
- Assemble the artifacts for our web service.
- Deploy the EAR file into the application server. We can now deploy the EAR file configured and enabled for web services onto the application server.
- Test the web service to make sure that the service works with the application server.
We have created a JAX-WS web service by starting with an existing WSDL file.
JAX-WS Set up a development environment for web services Generate Java artifacts for JAX-WS applications from a WSDL file Enable MTOM for JAX-WS web services Enforcing adherence to WSDL bindings in JAX-WS web services Developing a webservices.xml deployment descriptor for JAX-WS applications Completing the JavaBeans implementation for JAX-WS applications Completing the EJB implementation for JAX-WS applications Customizing URL patterns in the web.xml file for JAX-WS applications Assembling web services applications Deploy web services applications onto application servers Testing web services-enabled clients Use HTTP to transport web services Use SOAP over JMS to transport web services Example: Installing a web services sample with the console Implement web services applications with JAX-WS Artifacts used to develop web services Web services specifications and APIs Contexts and Dependency Injection (CDI) JAX-WS API documentation JAX-WS API User's Guide documentation