Refer to "5.1.1 What is a Web Service?" for an outline of Web services.
JAX-RS1.1 is included in Java EE 6.
By using JAX-RS1.1, Representational State Transfer (REST) type Web applications can easily be developed.
By using annotations in JAX-RS1.1, the Java resource path can be specified to easily bind the Java method to the HTTP request method.
Annotations
Use annotations to define classes to run as REST type Web applications.
The following shows annotations example:
@Path
This is used to define the root resource or sub resource Java method path.
@GET
This annotation specifies the "GET" HTTP request method. The root source or sub resource Java method can be bound to the "GET" HTTP request method.
@POST
This annotation specifies the "POST" HTTP request method. The root source or sub resource Java method can be bound to the "POST" HTTP request method.
@Produces
This generates the Java method of the root resource or sub resource, and shows the MIME media types that can be returned to the client.
@Consumes
The Java method of the root resource or sub resource indicates the MIME media types that can be received from the client.
Example of creating a REST type Web application using annotations
@Path(value="/root") public class RootResource { @GET public String getName() { return "name"; } } |
Point
Refer to the following specifications for details on JAX-RS 1.1:
JSR-311: JAX-RS: The Java(TM) API for RESTful Web Services
Refer to the following specifications for details on JAX-WS 2.2:
JSR 224: Java(TM) API for XML-Based Web Services (JAX-WS) 2.2
Refer to "5.2.2 Development Flow" and "5.2.3 Development Procedures" for information on the flow and procedures for developing Web service applications. Refer to "9.6.1 Preparing to Create Applications" for information on preparations for creating annotations.
Note
In the Java EE 6 workbench, the Service Endpoint Interface is generated from WSDL using the ijwsimport command.
Open the command prompt create the working folder.
Example: mkdir temp
Change to the working folder.
Example: cd temp
Create the source output destination folder.
Example: mkdir src
Use the ijwsimport command to generate the required source for the Web service client to the working folder.
ijwsimport -p <packagename> -s <sourceoutputfolder> -keep <WSDL URL (Uniform Resource Locator)>
Example: ijwsimport -p stub -s src -keep http://localhost:28282/WebServiceSample6/PopulationRankingService?wsdl
Copy the source files of the <source output folder> in 4 to each package folder in the Web service client project source folder. The WSDL files are unnecessary.
Select the Web service client project, then press the F5 key.
Delete the working folder.
If an error was detected in the source files that were added in 5 and 6 above, use the following procedure to set the build path:
Select the Web service client project, then select [Properties] from the context menu.
Click the [Java Build Path] > [Libraries] tabs, then add the following JAR files in [Add External JARs]:
<installation folder>\APS\F3FMisje6\glassfish\modules\endorsed
<installation folder>\APS\F3FMisje6\glassfish\lib\endorsed
In the [Order and Export] tab, move the JAR files that were added in 2 above [JRE System Library] then click [OK].
Refer to "Deploying and Obtaining/Storing WSDL" in "Developing Web Service Applications" in the "Interstage Application Server Java EE Operator's Guide (Java EE 6 Edition)" for details on the ijwsimport command and WSDL URL.
Point
Refer to "How to Create JAX-RS Applications" in the "Interstage Application Server Java EE Operator's Guide (Java EE 6 Edition)" for details on creating JAX-RS applications.