Implement Web services applications with JAX-WS
Use the JAX-WS model to develop Web services.
Best practice: IBM WAS supports the JAX-WS model and the JAX-RPC model. JAX-WS is the next generation Web services model extending the foundation provided by the JAX-RPC model. Using the strategic JAX-WS model, development of Web services and clients is simplified through support of a standards-based annotations model. Although the JAX-RPC model and applications are still supported, take advantage of the easy-to-implement JAX-WS model to develop new Web services applications and clients. bprac
To develop Web services based on the JAX-WS programming model, we can use a bottom-up development approach starting from existing Java Beansor 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 Java Beans 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, assemble all the artifacts that the Web service requires, and deploy the resulting application into the appserver 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, we are not required to package a WSDL file with the JAX-WS Web services.
- Considerations when using Java Beans
Java Beans exposed as JAX-WS Web services are supported only over an HTTP transport.
- Considerations when using enterprise beans
- The enterprise bean must be a stateless session bean.
- Enterprise beans that are exposed as JAX-WS Web services must be packaged in EJB 3.0 or higher modules.
- JAX-WS 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.
For transitioning users: In WAS V7.0, the default annotation support behavior has changed. In the V6.1 Feature Pack for Web services, the default behavior is to scan pre-Java EE 5 Web app modules to identify JAX-WS services and to scan pre-Java EE 5 Web app modules and EJB modules for service clients during application installation. For V 7.0, the default behavior is to not scan pre-Java EE 5 modules for annotations during application installation or server startup. You can preserve compatibility with feature packs from previous releases by either setting the UseWSFEP61ScanPolicy property in the META-INF/MANIFEST.MF of a WAR file or EJB module or by defining the Java virtual machine 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 documentation.trns
- Set up a development environment for Web services. You do not have to set up a development environment if we are using Rational Application Developer.
- Determine the existing Java Beans or enterprise beans to expose as a JAX-WS Web service.
- Develop a JAX-WS service endpoint implementation with annotations.
- Generate Java artifacts for JAX-WS applications.
Use JAX-WS tooling to generate the necessary JAX-WS and JAXB artifacts needed for JAX-WS Web services applications when starting from Java Beans or enterprise beans components.
If we are developing a service implementation bean that is invoked using the HTTP transport, then the WSDL file generated by the wsgen command-line tool during this step is optional. However, if we are developing a service implementation bean that is invoked using the SOAP over JMS transport, then the WSDL file generated by the wsgen tool during this step is required in subsequent steps, and therefore, not optional.
- (optional) Enable MTOM for JAX-WS Web services. Use SOAP Message Transmission Optimization Mechanism (MTOM) to optimize the transmission of binary attachments, such as images or files along with Web services requests.
- (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 the JAX-WS Web services.
- Complete the implementation of the Web services application.
- For Java Beans applications, complete the Java Beans implementation.
- For enterprise beans applications, complete the enterprise beans implementation.
- (Optional) Customize URL patterns in web.xml. When Java Beans are exposed as JAX-WS endpoints, optionally customize the URL patterns within the web.xml deployment descriptor contained in the WAR file.
- Assemble the artifacts for the Web service.
Use assembly tools provided with the appserver to assemble the Java -based Web services modules.
If we have assembled an EAR file that contains enterprise beans modules that include Web services, use the endptEnabler command-line tool or an assembly tool before deployment to produce a Web services endpoint WAR file. This tool is also used to specify whether the Web services are exposed using SOAP over JMS or SOAP over HTTP.
- Deploy the EAR file into the appserver. We can now deploy the EAR file that has been configured and enabled for JAX-WS Web services onto the appserver.
Results
we have developed a JAX-WS application.
Next steps
After you deploy the EAR file, test the Web service to make sure that the service works with the appserver.
Set up a development environment for Web services
Develop a JAX-WS service endpoint implementation with annotations
Generating Java artifacts for JAX-WS applications
Enable MTOM for JAX-WS Web services
Develop a webservices.xml deployment descriptor for JAX-WS applications
Completing the Java Beans implementation for JAX-WS applications
Completing the EJB implementation for JAX-WS applications
Customizing URL patterns in web.xml for JAX-WS applications 
Related concepts
JAX-WS
Web services
Related tasks
Assemble Web services applications
Deploy Web services applications onto appservers
Use HTTP to transport Web services
Use SOAP over Java Message Service to transport Web services
Example: Installing a Web Services Sample with the console
Implement Web services applications from existing WSDL files with JAX-WS
Related
Artifacts used to develop Web services
JAX-WS annotations
Web services specifications and APIs 
Related information
Java API for XML Web Services (JAX-WS) API documentation
Java API for XML Web Services (JAX-WS) API User's Guide documentation