Java API for XML Web Services (JAX-WS) 2.0,JSR 224 is an important part of the Java EE 5 platform. A follow-on release of the Java API for xml-based RPC 1.1 (JAX-RPC), Jax-ws simplifies the work of developing WEB services using Java technology. It addresses some of the problems that are present in Jax-RPC 1.1 through support for multiple protocols such as SOAP 1.1, SOAP 1.2, XML, and tools to support other protocols and HTTP. JAX-WS uses JAXB 2.0 to provide data binding services and enables customization to control the generated service endpoint interfaces. With the support for annotations, JAX-WS simplifies WEB service development and reduces the size of runtime JAR files.
This document introduces you to the basics of using the IDE to develop JAX-WS WEB services and to use the service in three different clients (Java classes in Java SE applications, Servlet or JSP pages in a WEB application). The three clients created in this document are stand-alone applications that use the same Web service.
Installing and configuring the tutorial environment
If you have not yet registered an instance of Sun Java System application Server 9.0, you must register before you can start developing Java EE 5 Applications:
From the main window, select Tools > Server Manager.
Click Add Server. Select Sun Java System application Server, and specify a name for this instance, and then click Next.
Specifies the server information, the location of the local instance of the application server, and the domain to which the WEB service is deployed.
Click Finish.
Note: You can also deploy to Tomcat Web Server, but because it has only one web container, you should create the Web application in the next section, not the EJB module. Unlike JSR-109 Web services, JAX-WS Web services can be successfully deployed to the TOMCAT Web container.
Creating a Web Service
The purpose of this exercise is to create a project that applies to the deployment container that you decide to use. After the project is established, you will create a WEB service in it.
Select container
You can deploy Web services in a Web container or in an EJB container. It depends on the specific choice. For example, if you plan to deploy to a Tomcat Web Server that has only a web container, you should choose to create a Web application instead of an EJB module.
Select File > New Project (ctrl-shift-n). From the Web category, select Web Application, or from the Enterprise category, select EJB module.
Name the project Calculatorwsapplication.
Depending on the deployment server that you want to use, do the following:
For the Sun Java System application Server, the Java EE version is set to 5.
For Tomcat Web Server, uncheck the set source code level to 1.4 check box.
Click Finish.
Creating a Web service from a Java class
Right-click the Calculatorwsapplication node and choose New > Web service.
Name the Web service Calculatorws, type Org.me.calculator in package, and then click Finish.
The new WEB service is displayed in the Projects window. For example, for a WEB application, the Projects window now looks like this:
The IDE will automatically create the deployment descriptor (if any) required for the server. For the Sun Java System application Server, you do not need to deploy a descriptor. For Web services deployed to Tomcat Web Server, the Sun-jaxws.xml and Wsservlet entries in Web.xml are added.