See: Description
| Class | Description |
|---|---|
| WebResourceFactory |
Factory for client-side representation of a resource.
|
Consider a server which exposes a resource at http://localhost:8080. The resource can be described by the following interface:
@Path("myresource")
public interface MyResourceIfc {
@GET
@Produces("text/plain")
String get();
@POST
@Consumes("application/xml")
@Produces("application/xml")
MyBean postEcho(MyBean bean);
@Path("{id}")
@GET
@Produces("text/plain")
String getById(@PathParam("id") String id);
}
You can use WebResourceFactory class defined in this package to access the server-side resource using this interface. Here is an example:
Client c = ClientBuilder.newClient();
MyResourceIfc resource = WebResourceFactory.newWebResource(MyResourceIfc.class, c, "http://localhost:8080/");
String responseFromGet = resource.get();
MyBean responseFromPost = resource.postEcho(myBeanInstance);
String responseFromGetById = resource.getById("abc");
Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.