![[8.5.5.4 or later]](../../images/ng_v8554.gif)
Generating sample client code for a JAX-RS 2.0 resource
You can generate sample client code for a Java™ API for RESTful Web Services (JAX-RS) resource from a REST project address.
Before you begin
Important: Applicable to Liberty
Complete the following setup for WebSphere® Application
Server Developer Tools for Eclipse:
- Add the Liberty run time to the preferences.
- Create a Liberty server in the Servers view.
- Create a web project with one or more REST services that are defined in the project. Otherwise, if you do not define any services, the REST node has no children.
Procedure
Results
If you
completed the optional step to generate JAXB classes, you also generated JAXB classes into the same
project as your JAX-RS client.
You also generated a new Java class file by using the JAX-RS 2.0 Client API that can be used to access the JAX-RS service. Every annotated method of the JAX-RS service has a corresponding JAX-RS client method, which is generated from annotations on the JAX-RS service methods. The JAX-RS service methods include @PathParam; @QueryParam; @Consumes; @Produces; @Path; and resource methods such as @GET, @PUT, or @POST.
Restriction: All classes that are affected by the JAX-RS client generation algorithm must adhere to the
following restrictions:
- These classes must be a string, a primitive, a JAX-RS API class, or a user class that is annotated by Java Architecture for XML Binding (JAXB). These classes cannot be binary.
- All classes must be in source form in order for the algorithm to locate them. If the classes are not in the same project as the JAX-RS service, the JAX-RS client cannot be generated.