public class WebClient extends AbstractClient
AbstractClient.AbstractBodyWriter, AbstractClient.AbstractClientAsyncResponseInterceptorcfg, EXECUTOR_SERVICE_PROPERTY, HTTP_SCHEME, KEEP_CONDUIT_ALIVE, REQUEST_CONTEXT, RESPONSE_CONTEXT| Modifier | Constructor and Description |
|---|---|
protected |
WebClient(ClientState state) |
protected |
WebClient(String baseAddress) |
protected |
WebClient(URI baseURI) |
| Modifier and Type | Method and Description |
|---|---|
WebClient |
accept(javax.ws.rs.core.MediaType... types)
Set HTTP Accept header
|
WebClient |
accept(String... types)
Set HTTP Accept header
|
WebClient |
acceptEncoding(String... encodings)
Set HTTP Accept-Encoding header
|
WebClient |
acceptLanguage(String... languages)
Set HTTP Accept-Language header
|
javax.ws.rs.client.AsyncInvoker |
async() |
WebClient |
back(boolean fast)
Goes back
|
static Client |
client(Object object)
Converts object to Client
|
WebClient |
cookie(javax.ws.rs.core.Cookie cookie)
Set HTTP Cookie header
|
static WebClient |
create(String baseAddress)
Creates WebClient
|
static WebClient |
create(String baseURI,
boolean threadSafe)
Creates WebClient
|
static WebClient |
create(String baseAddress,
List<?> providers)
Creates WebClient
|
static WebClient |
create(String baseAddress,
List<?> providers,
boolean threadSafe)
Creates WebClient
|
static WebClient |
create(String baseAddress,
List<?> providers,
List<? extends Feature> features,
String configLocation)
Creates WebClient with a list of custom features
|
static WebClient |
create(String baseAddress,
List<?> providers,
long timeToKeepState)
Creates a thread safe WebClient
|
static WebClient |
create(String baseAddress,
List<?> providers,
String configLocation)
Creates WebClient
|
static WebClient |
create(String baseAddress,
List<?> providers,
String username,
String password,
String configLocation)
Creates WebClient which will do basic authentication
|
static WebClient |
create(String baseAddress,
String configLocation)
Creates WebClient
|
static WebClient |
create(String baseAddress,
String username,
String password,
String configLocation)
Creates WebClient which will do basic authentication
|
static WebClient |
create(URI baseURI)
Creates WebClient
|
javax.ws.rs.core.Response |
delete()
Does HTTP DELETE invocation
|
protected javax.ws.rs.core.Response |
doChainedInvocation(String httpMethod,
javax.ws.rs.core.MultivaluedMap<String,String> headers,
Object body,
Class<?> requestClass,
Type inType,
Annotation[] inAnns,
Class<?> respClass,
Type outType,
Exchange exchange,
Map<String,Object> invContext) |
protected javax.ws.rs.core.Response |
doInvoke(String httpMethod,
Object body,
Class<?> requestClass,
Type inGenericType,
Class<?> responseClass,
Type outGenericType) |
protected javax.ws.rs.core.Response |
doInvoke(String httpMethod,
Object body,
Type inGenericType,
Class<?> responseClass,
Type outGenericType) |
protected <T> Future<T> |
doInvokeAsync(String httpMethod,
Object body,
Class<?> requestClass,
Type inType,
Class<?> respClass,
Type outType,
javax.ws.rs.client.InvocationCallback<T> callback) |
protected <T> Future<T> |
doInvokeAsyncCallback(String httpMethod,
Object body,
Class<?> requestClass,
Type inType,
javax.ws.rs.client.InvocationCallback<T> callback) |
protected javax.ws.rs.core.Response |
doResponse(Message m,
Class<?> responseClass,
Type outGenericType) |
WebClient |
encoding(String encoding)
Set HTTP Content-Encoding header
|
javax.ws.rs.core.Response |
form(javax.ws.rs.core.Form form)
Posts form data
|
javax.ws.rs.core.Response |
form(Map<String,List<Object>> values)
Posts form data
|
WebClient |
fragment(String name)
Updates the current URI fragment
|
static WebClient |
fromClient(Client client)
Creates WebClient, baseURI will be set to Client currentURI
|
static WebClient |
fromClient(Client client,
boolean inheritHeaders)
Creates WebClient, baseURI will be set to Client currentURI
|
static WebClient |
fromClientObject(Object object)
Creates WebClient, baseURI will be set to Client currentURI
|
javax.ws.rs.core.Response |
get()
Does HTTP GET invocation
|
<T> T |
get(Class<T> responseClass)
Does HTTP GET invocation and returns typed response object
|
<T> T |
get(javax.ws.rs.core.GenericType<T> responseType)
Does HTTP GET invocation and returns typed response object
|
<T> Future<T> |
get(javax.ws.rs.client.InvocationCallback<T> callback)
Does HTTP Async GET invocation and returns Future.
|
<T> Collection<? extends T> |
getCollection(Class<T> memberClass)
Does HTTP GET invocation and returns a collection of typed objects
|
static ClientConfiguration |
getConfig(Object client)
Retrieves ClientConfiguration
|
protected javax.ws.rs.core.Response |
handleResponse(Message outMessage,
Class<?> responseClass,
Type genericType) |
javax.ws.rs.core.Response |
head()
Does HTTP HEAD invocation
|
WebClient |
header(String name,
Object... values)
Set arbitrary HTTP Header
|
WebClient |
headers(javax.ws.rs.core.MultivaluedMap<String,String> map)
Set HTTP Headers
|
javax.ws.rs.core.Response |
invoke(String httpMethod,
Object body)
Does HTTP invocation
|
<T> T |
invoke(String httpMethod,
Object body,
Class<?> requestClass,
Class<T> responseClass)
Does HTTP invocation and returns types response object
|
<T> T |
invoke(String httpMethod,
Object body,
Class<T> responseClass)
Does HTTP invocation and returns types response object
|
<T> T |
invoke(String httpMethod,
Object body,
javax.ws.rs.core.GenericType<T> responseType)
Does HTTP invocation and returns types response object
|
<T> Collection<? extends T> |
invokeAndGetCollection(String httpMethod,
Object body,
Class<T> memberClass)
Does HTTP invocation and returns a collection of typed objects
|
WebClient |
language(String language)
Set HTTP Content-Language header
|
WebClient |
match(javax.ws.rs.core.EntityTag tag,
boolean ifNot)
Set HTTP If-Match or If-None-Match header
|
WebClient |
matrix(String name,
Object... values)
Updates the current URI matrix parameters
|
WebClient |
modified(Date date,
boolean ifNot)
Set HTTP If-Modified-Since or If-Unmodified-Since header
|
javax.ws.rs.core.Response |
options()
Does HTTP OPTIONS invocation
|
WebClient |
path(Object path)
Updates the current URI path
|
WebClient |
path(String path,
Object... values)
Updates the current URI path with path segment which may contain template variables
|
javax.ws.rs.core.Response |
post(Object body)
Does HTTP POST invocation
|
<T> T |
post(Object body,
Class<T> responseClass)
Does HTTP POST invocation and returns typed response object
|
<T> T |
post(Object body,
javax.ws.rs.core.GenericType<T> responseType)
Does HTTP POST invocation and returns typed response object
|
<T> Future<T> |
post(Object body,
javax.ws.rs.client.InvocationCallback<T> callback)
Does HTTP Async POST invocation and returns Future.
|
<T> Collection<? extends T> |
postAndGetCollection(Object body,
Class<T> memberClass)
Posts request body and returns a collection of typed objects
|
<T1,T2> Collection<? extends T2> |
postAndGetCollection(Object collection,
Class<T1> memberClass,
Class<T2> responseClass)
Posts collection of typed objects and returns a collection of typed objects
|
<T> javax.ws.rs.core.Response |
postCollection(Object collection,
Class<T> memberClass)
Posts a collection of typed objects
|
<T1,T2> T2 |
postCollection(Object collection,
Class<T1> memberClass,
Class<T2> responseClass)
Posts a collection of typed objects
|
<T> Collection<? extends T> |
postObjectGetCollection(Object body,
Class<T> responseClass)
Posts the object and returns a collection of typed objects
|
protected void |
prepareAsyncClient(String httpMethod,
Object body,
Class<?> requestClass,
Type inType,
Class<?> respClass,
Type outType,
JaxrsClientCallback<?> cb) |
javax.ws.rs.core.Response |
put(Object body)
Does HTTP PUT invocation
|
<T> T |
put(Object body,
Class<T> responseClass)
Does HTTP PUT invocation and returns typed response object
|
<T> T |
put(Object body,
javax.ws.rs.core.GenericType<T> responseType)
Does HTTP PUT invocation and returns typed response object
|
<T> Future<T> |
put(Object body,
javax.ws.rs.client.InvocationCallback<T> callback)
Does HTTP Async PUT invocation and returns Future.
|
WebClient |
query(String name,
Object... values)
Update the current URI query parameters
|
WebClient |
replaceHeader(String headerName,
Object value)
Replaces the header value with the new values.
|
WebClient |
replacePath(String path)
Replaces the current path with the new value.
|
WebClient |
replaceQuery(String queryString)
Replaces the current query with the new value.
|
WebClient |
replaceQueryParam(String queryParam,
Object... value)
Replaces the current query with the new value.
|
WebClient |
reset()
Reset the headers and response state if any
|
WebClient |
resetQuery()
Resets the current query
|
protected Object |
retryInvoke(URI newRequestURI,
javax.ws.rs.core.MultivaluedMap<String,String> headers,
Object body,
Exchange exchange,
Map<String,Object> invContext) |
javax.ws.rs.client.CompletionStageRxInvoker |
rx() |
<T extends javax.ws.rs.client.RxInvoker> |
rx(Class<T> rxCls) |
<T extends javax.ws.rs.client.RxInvoker> |
rx(Class<T> rxCls,
ExecutorService executorService) |
javax.ws.rs.client.CompletionStageRxInvoker |
rx(ExecutorService ex) |
javax.ws.rs.client.SyncInvoker |
sync() |
WebClient |
to(String newAddress,
boolean forward)
Moves WebClient to a new baseURI or forwards to new currentURI
|
WebClient |
type(javax.ws.rs.core.MediaType ct)
Set HTTP Content-Type header
|
WebClient |
type(String type)
Set HTTP Content-Type header
|
addMatrixQueryParamsToBuilder, authorization, calculateNewRequestURI, checkClientException, checkIfBodyEmpty, close, completeExchange, convertParamValue, convertParamValue, convertToWebApplicationException, createExchange, createMessage, doRunInterceptorChain, findCallbackType, getBaseURI, getCallbackClass, getCallbackType, getConfiguration, getContentsList, getCurrentBuilder, getCurrentURI, getHeaders, getRequestContext, getResponse, getState, getTemplateParametersMap, parseQuotedHeaderValue, prepareConduitSelector, preProcessResult, readBody, reportMessageHandlerProblem, resetBaseAddress, resetCurrentBuilder, resetResponse, resetResponseStateImmediatelyIfNeeded, responseStreamCanBeClosed, retryInvoke, setAllHeaders, setAsyncMessageObserverIfNeeded, setConfiguration, setContexts, setEmptyRequestPropertyIfNeeded, setPlainOperationNameProperty, setResponseBuilder, setSupportOnewayResponseProperty, setupInFaultObserver, setupInInterceptorChain, setupOutInterceptorChain, waitForResponseCode, writeBodyprotected WebClient(String baseAddress)
protected WebClient(URI baseURI)
protected WebClient(ClientState state)
public static WebClient create(String baseAddress)
baseAddress - baseAddresspublic static WebClient create(String baseURI, boolean threadSafe)
baseURI - baseURIpublic static WebClient create(String baseAddress, List<?> providers)
baseAddress - baseURIproviders - list of providerspublic static WebClient create(String baseAddress, List<?> providers, boolean threadSafe)
baseAddress - baseURIproviders - list of providersthreadSafe - if true ThreadLocalClientState is usedpublic static WebClient create(String baseAddress, List<?> providers, long timeToKeepState)
baseAddress - baseURIproviders - list of providerstimeToKeepState - time to keep this thread safe state.public static WebClient create(String baseAddress, List<?> providers, String configLocation)
baseAddress - baseAddressproviders - list of providersconfigLocation - classpath location of the configuration resource, can be nullpublic static WebClient create(String baseAddress, List<?> providers, List<? extends Feature> features, String configLocation)
baseAddress - baseAddressproviders - list of providersfeatures - the features which will be applied to the clientconfigLocation - classpath location of the configuration resource, can be nullpublic static WebClient create(String baseAddress, String configLocation)
baseAddress - baseAddressconfigLocation - classpath location of the configuration resource, can be nullpublic static WebClient create(String baseAddress, String username, String password, String configLocation)
baseAddress - baseAddressusername - usernamepassword - passwordconfigLocation - classpath location of the configuration resource, can be nullpublic static WebClient create(String baseAddress, List<?> providers, String username, String password, String configLocation)
baseAddress - baseAddressproviders - list of providersusername - usernamepassword - passwordconfigLocation - classpath location of the configuration resource, can be nullpublic static WebClient fromClientObject(Object object)
object - existing client objectpublic static WebClient fromClient(Client client)
client - existing clientpublic static WebClient fromClient(Client client, boolean inheritHeaders)
client - existing clientinheritHeaders - if existing Client headers can be inherited by new clientpublic static Client client(Object object)
object - the objectpublic static ClientConfiguration getConfig(Object client)
client - proxy or http-centric Clientpublic javax.ws.rs.core.Response invoke(String httpMethod, Object body)
httpMethod - HTTP methodbody - request body, can be nullpublic javax.ws.rs.core.Response post(Object body)
body - request body, can be nullpublic javax.ws.rs.core.Response put(Object body)
body - request body, can be nullpublic javax.ws.rs.core.Response get()
public javax.ws.rs.core.Response head()
public javax.ws.rs.core.Response options()
public javax.ws.rs.core.Response delete()
public javax.ws.rs.core.Response form(Map<String,List<Object>> values)
values - form valuespublic javax.ws.rs.core.Response form(javax.ws.rs.core.Form form)
form - form valuespublic <T> T invoke(String httpMethod, Object body, javax.ws.rs.core.GenericType<T> responseType)
httpMethod - HTTP methodbody - request body, can be nullresponseType - generic response typepublic <T> T invoke(String httpMethod, Object body, Class<T> responseClass)
httpMethod - HTTP methodbody - request body, can be nullresponseClass - expected type of response objectpublic <T> T invoke(String httpMethod, Object body, Class<?> requestClass, Class<T> responseClass)
httpMethod - HTTP methodbody - request body, can be nullrequestClass - request body classresponseClass - expected type of response objectpublic <T> T post(Object body, Class<T> responseClass)
body - request body, can be nullresponseClass - expected type of response objectpublic <T> T post(Object body, javax.ws.rs.core.GenericType<T> responseType)
body - request body, can be nullresponseType - generic response typepublic <T> Future<T> post(Object body, javax.ws.rs.client.InvocationCallback<T> callback)
callback - invocation callbackpublic <T> T put(Object body, Class<T> responseClass)
body - request body, can be nullresponseClass - expected type of response objectpublic <T> T put(Object body, javax.ws.rs.core.GenericType<T> responseType)
body - request body, can be nullresponseType - generic response typepublic <T> Future<T> put(Object body, javax.ws.rs.client.InvocationCallback<T> callback)
callback - invocation callbackpublic <T> Collection<? extends T> invokeAndGetCollection(String httpMethod, Object body, Class<T> memberClass)
httpMethod - HTTP methodbody - request body, can be nullmemberClass - expected type of collection member classpublic <T> javax.ws.rs.core.Response postCollection(Object collection, Class<T> memberClass)
collection - request bodymemberClass - type of collection member classpublic <T1,T2> T2 postCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass)
collection - request bodymemberClass - type of collection member classresponseClass - expected type of response objectpublic <T1,T2> Collection<? extends T2> postAndGetCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass)
collection - request bodymemberClass - type of collection member classresponseClass - expected type of response objectpublic <T> Collection<? extends T> postObjectGetCollection(Object body, Class<T> responseClass)
body - request bodyresponseClass - expected type of response objectpublic <T> Collection<? extends T> postAndGetCollection(Object body, Class<T> memberClass)
body - request body, can be nullmemberClass - expected type of collection member classpublic <T> Collection<? extends T> getCollection(Class<T> memberClass)
memberClass - expected type of collection member classpublic <T> T get(Class<T> responseClass)
responseClass - expected type of response objectpublic <T> T get(javax.ws.rs.core.GenericType<T> responseType)
responseType - generic response typepublic <T> Future<T> get(javax.ws.rs.client.InvocationCallback<T> callback)
callback - invocation callbackpublic WebClient path(Object path)
path - new relative path segmentpublic WebClient path(String path, Object... values)
path - new relative path segmentvalues - template variable valuespublic WebClient query(String name, Object... values)
AbstractClientquery in interface Clientquery in class AbstractClientname - query namevalues - query valuespublic WebClient matrix(String name, Object... values)
name - matrix namevalues - matrix valuespublic WebClient fragment(String name)
name - fragment namepublic WebClient to(String newAddress, boolean forward)
newAddress - new URIforward - if true then currentURI will be based on baseURIpublic WebClient back(boolean fast)
fast - if true then goes back to baseURI otherwise to a previous path segmentpublic WebClient replacePath(String path)
path - new path value. If it starts from "/" then all the current
path starting from the base URI will be replaced, otherwise only the
last path segment will be replaced. Providing a null value is equivalent
to calling back(true)public WebClient resetQuery()
public WebClient replaceQuery(String queryString)
queryString - the new value, providing a null is
equivalent to calling resetQuery().public WebClient replaceHeader(String headerName, Object value)
headerName - headerValuesvalue - new values, null is equivalent to removing the headerpublic WebClient replaceQueryParam(String queryParam, Object... value)
queryParam - query param namevalue - the new value, providing a null is
equivalent to calling resetQuery().public WebClient type(javax.ws.rs.core.MediaType ct)
AbstractClienttype in interface Clienttype in class AbstractClientct - JAXRS MediaType representing Content-Type valuepublic WebClient type(String type)
AbstractClienttype in interface Clienttype in class AbstractClienttype - Content-Type valuepublic WebClient accept(javax.ws.rs.core.MediaType... types)
AbstractClientaccept in interface Clientaccept in class AbstractClienttypes - list of JAXRS MediaTypes representing Accept header valuespublic WebClient accept(String... types)
AbstractClientaccept in interface Clientaccept in class AbstractClienttypes - list of Accept header valuespublic WebClient language(String language)
AbstractClientlanguage in interface Clientlanguage in class AbstractClientlanguage - Content-Language header valuepublic WebClient acceptLanguage(String... languages)
AbstractClientacceptLanguage in interface ClientacceptLanguage in class AbstractClientlanguages - list of Accept-Language header valuespublic WebClient encoding(String encoding)
AbstractClientencoding in interface Clientencoding in class AbstractClientencoding - Content-Encoding header valuepublic WebClient acceptEncoding(String... encodings)
AbstractClientacceptEncoding in interface ClientacceptEncoding in class AbstractClientencodings - list of Accept-Encoding header valuepublic WebClient match(javax.ws.rs.core.EntityTag tag, boolean ifNot)
AbstractClientmatch in interface Clientmatch in class AbstractClienttag - ETag valueifNot - if true then If-None-Match is set, If-Match otherwisepublic WebClient modified(Date date, boolean ifNot)
AbstractClientmodified in interface Clientmodified in class AbstractClientdate - Date value, will be formated as "EEE, dd MMM yyyy HH:mm:ss zzz"ifNot - if true then If-Unmodified-Since is set, If-Modified-Since otherwisepublic WebClient cookie(javax.ws.rs.core.Cookie cookie)
AbstractClientcookie in interface Clientcookie in class AbstractClientcookie - Cookie valuepublic WebClient header(String name, Object... values)
AbstractClientheader in interface Clientheader in class AbstractClientname - header namevalues - list of header valuespublic WebClient headers(javax.ws.rs.core.MultivaluedMap<String,String> map)
AbstractClientheaders in interface Clientheaders in class AbstractClientmap - headerspublic WebClient reset()
AbstractClientreset in interface Clientreset in class AbstractClientprotected javax.ws.rs.core.Response doInvoke(String httpMethod, Object body, Type inGenericType, Class<?> responseClass, Type outGenericType)
protected javax.ws.rs.core.Response doInvoke(String httpMethod, Object body, Class<?> requestClass, Type inGenericType, Class<?> responseClass, Type outGenericType)
protected <T> Future<T> doInvokeAsyncCallback(String httpMethod, Object body, Class<?> requestClass, Type inType, javax.ws.rs.client.InvocationCallback<T> callback)
protected <T> Future<T> doInvokeAsync(String httpMethod, Object body, Class<?> requestClass, Type inType, Class<?> respClass, Type outType, javax.ws.rs.client.InvocationCallback<T> callback)
protected void prepareAsyncClient(String httpMethod, Object body, Class<?> requestClass, Type inType, Class<?> respClass, Type outType, JaxrsClientCallback<?> cb)
protected Object retryInvoke(URI newRequestURI, javax.ws.rs.core.MultivaluedMap<String,String> headers, Object body, Exchange exchange, Map<String,Object> invContext) throws Throwable
retryInvoke in class AbstractClientThrowableprotected javax.ws.rs.core.Response doChainedInvocation(String httpMethod, javax.ws.rs.core.MultivaluedMap<String,String> headers, Object body, Class<?> requestClass, Type inType, Annotation[] inAnns, Class<?> respClass, Type outType, Exchange exchange, Map<String,Object> invContext)
protected javax.ws.rs.core.Response doResponse(Message m, Class<?> responseClass, Type outGenericType)
protected javax.ws.rs.core.Response handleResponse(Message outMessage, Class<?> responseClass, Type genericType)
public javax.ws.rs.client.AsyncInvoker async()
public javax.ws.rs.client.SyncInvoker sync()
public javax.ws.rs.client.CompletionStageRxInvoker rx()
public javax.ws.rs.client.CompletionStageRxInvoker rx(ExecutorService ex)
public <T extends javax.ws.rs.client.RxInvoker> T rx(Class<T> rxCls)
public <T extends javax.ws.rs.client.RxInvoker> T rx(Class<T> rxCls, ExecutorService executorService)
Apache CXF