Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

## Package com.sun.jersey.api.client

Provides support for client-side communication with HTTP-based RESTful Web services.

See:
Description

Interface Summary
AsyncUniformInterface | An asynchronous uniform interface for invoking HTTP requests.
AsyncViewUniformInterface |
ClientHandler | A client handler that handles a HTTP request and returns the HTTP response.
ClientRequestAdapter | Adapter for the client request to adapt the output stream to write the entity.
RequestBuilder<T extends RequestBuilder> | An interface for building requests.
RequestWriter.RequestEntityWriter | A writer for writing a request entity.
RequestWriter.RequestEntityWriterListener | A lister for listening to events when writing a request entity.
UniformInterface | A uniform interface for invoking HTTP requests.
ViewUniformInterface |

Class Summary
AbstractClientRequestAdapter | Abstract implementation of ClientRequestAdapter that helps to adapt an existing ClientRequestAdapter instance.
AsyncViewResource |
AsyncWebResource | An encapsulation of an asynchronous Web resource capable of building requests to send to the Web resource and processing responses returned from the Web resource.
Client | The main class for creating `WebResource` instances and configuring the properties of connections and requests.
ClientRequest | A client (out-bound) HTTP request.
ClientRequest.Builder | The builder for building a `ClientRequest` instance.
ClientResponse | A client (in-bound) HTTP response.
CommittingOutputStream | A commiting output stream that commits before the first byte is written to the adapted `OutputStream`.
GenericType<T> | Represents a generic type `T`.
PartialRequestBuilder<T extends RequestBuilder> | A partial implementation of `RequestBuilder` that implements the methods on `RequestBuilder` but leaves undefined the build methods for constructing the request.
RequestWriter | A request writer for writing header values and a request entity.
TerminatingClientHandler | A terminating client handler that is invoked to produce an HTTP request to send to a resource and process the HTTP response received from the resource.
ViewResource |
WebResource | An encapsulation of a Web resource capable of building requests to send to the Web resource and processing responses returned from the Web resource.
WebResourceLinkHeaders |

Enum Summary
ClientResponse.Status | Status codes defined by HTTP, see HTTP/1.1 documentation.

Exception Summary
ClientHandlerException | A runtime exception thrown by a client handler that signals a failure to process the HTTP request or HTTP response.
UniformInterfaceException | A runtime exception thrown by a method on the `UniformInterface` or `ClientResponse` when the status code of the HTTP response indicates a response that is not expected.

## Package com.sun.jersey.api.client Description

Provides support for client-side communication with HTTP-based RESTful Web services.

The client API is high-level API that reuses many aspects of the JAX-RS API. It is designed to be quick, easy to use and is especially useful and productive when developing tests for Web services.

The client API can be used as follows to make simple GET and POST requests to a Web resource:

>          Client c = Client.create();
>          WebResource r = c.resource("http://host/base");
>          String s = r.get(String.class);
>          s = r.post(String.class, s);

A key concept of REST is the uniform interface and this is encapsulated in the `WebResource` class, which implements `UniformInterface`. A request is built up and when the corresponding HTTP method on the `UniformInterface` is invoked the request is sent to the Web resource and the returned response is processed. This enables efficient production of requests as follows:

>          WebResource r = ...
>          String s = r.accept("application/xml").get(String.class);
>          s = r.accept("application/xml").type("application/xml").post(String.class, s);

In the above example a GET request occurs stating that the "application/xml" is acceptable. After that a POST request occurs stating the same acceptable media type and that the content type of the request entity is "application/xml".

The Java types that may be used for request and response entities are not restricted to `String`. The client API reuses the same infrastrucure as JAX-RS server-side. Thus the same types that can be used on the server-side can also be used on the client-side, such as JAXB-based types. Further more the supported Java types can be extended by implementing `MessageBodyReader` and `MessageBodyWriter`. For registration of such support for new Java types see `ClientConfig`.

A type of `ClientResponse` declared for the response entity may be used to obtain the status, headers and response entity.

If any type, other than `ClientResponse`, is declared and the response status is greater than or equal to 300 then a `UniformInterfaceException` exception will be thrown, from which the `ClientResponse` instance can be accessed.

In the following cases it is necessary to close the response, when response processing has completed, to ensure that underlying resources are correctly released.

If a response entity is declared of the type `ClientResponse` or of a type that is assignable to `Closeable` (such as `InputStream`) then the response must be either: 1) closed by invoking the method `ClientResponse.close()` or `Closeable.close()`; or 2) all bytes of response entity must be read.

If a `UniformInterfaceException` is thrown then by default the response entity is automatically buffered and the underlying resources are correctly released. See the following property for more details: `ClientConfig.PROPERTY_BUFFER_RESPONSE_ENTITY_ON_EXCEPTION`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES

Copyright © 2013 Oracle Corporation. All Rights Reserved.