In this section, we will use the Jersey client API to create a JAX-RS Web Service client. Create a Java class for a Java client. Select File | New | Other. In New, select Class and click on Next. In the New Java Class wizard, select Source folder as src/main/java
, specify Package as org.jboss.jaxrs.rest
, and Name as JAXRSClient
, which is shown as follows. Then click on Finish.
The org.jboss.jaxrs.rest.JAXRSClient
class gets created, as shown here:
Jersey provides a client API to invoke a JAX-RS Web Service. In the Java client, invoke the resource methods using the Jersey client API. Create a resource instance using the com.sun.jersey.api.client.Client
class. First, we need to create a ClientConfig
object, which represents the client configuration such as property names and features using the no-arguments constructor for DefaultClientConfig
. Create a Client
object from the ClientConfig
object using the static method create(ClientConfig)
. Create a WebResource
object from...