|
Apache CXF API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cxf.jaxrs.client.AbstractClient org.apache.cxf.jaxrs.client.WebClient
public class WebClient
Http-centric web client
Field Summary |
---|
Fields inherited from class org.apache.cxf.jaxrs.client.AbstractClient |
---|
cfg, KEEP_CONDUIT_ALIVE, REQUEST_CONTEXT, RESPONSE_CONTEXT |
Constructor Summary | |
---|---|
protected |
WebClient(ClientState state)
|
protected |
WebClient(String baseAddress)
|
protected |
WebClient(URI baseAddress)
|
Method Summary | ||
---|---|---|
WebClient |
accept(javax.ws.rs.core.MediaType... types)
sets HTTP Accept header |
|
WebClient |
accept(String... types)
sets HTTP Accept header |
|
WebClient |
acceptEncoding(String... encodings)
sets HTTP Accept-Encoding header |
|
WebClient |
acceptLanguage(String... languages)
sets HTTP Accept-Language header |
|
WebClient |
back(boolean fast)
Goes back |
|
static Client |
client(Object proxy)
Converts proxy to Client |
|
WebClient |
cookie(javax.ws.rs.core.Cookie cookie)
sets 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,
String configLocation)
Creates a Spring-configuration aware WebClient |
|
static WebClient |
create(String baseAddress,
String configLocation)
Creates a Spring-configuration aware WebClient |
|
static WebClient |
create(String baseAddress,
String username,
String password,
String configLocation)
Creates a Spring-configuration aware 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,
Type inGenericType,
Class<?> responseClass,
Type outGenericType,
Exchange exchange,
Map<String,Object> invContext)
|
|
protected javax.ws.rs.core.Response |
doInvoke(String httpMethod,
Object body,
Type inGenericType,
Class<?> responseClass,
Type outGenericType)
|
|
WebClient |
encoding(String encoding)
sets HTTP Content-Encoding header |
|
javax.ws.rs.core.Response |
form(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 |
|
javax.ws.rs.core.Response |
get()
Does HTTP GET invocation |
|
|
get(Class<T> responseClass)
Does HTTP GET invocation and returns typed response object |
|
|
getCollection(Class<T> memberClass)
Does HTTP GET invocation and returns a collection of typed objects |
|
static ClientConfiguration |
getConfig(Object client)
Retieves 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)
Sets arbitrary HTTP Header |
|
WebClient |
headers(javax.ws.rs.core.MultivaluedMap<String,String> map)
Sets HTTP Headers |
|
javax.ws.rs.core.Response |
invoke(String httpMethod,
Object body)
Does HTTP invocation |
|
|
invoke(String httpMethod,
Object body,
Class<T> responseClass)
Does HTTP invocation and returns types response object |
|
|
invokeAndGetCollection(String httpMethod,
Object body,
Class<T> memberClass)
Does HTTP invocation and returns a collection of typed objects |
|
WebClient |
language(String language)
sets HTTP Content-Language header |
|
WebClient |
match(javax.ws.rs.core.EntityTag tag,
boolean ifNot)
sets 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)
sets 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 |
|
|
post(Object body,
Class<T> responseClass)
Does HTTP POST invocation and returns typed response object |
|
|
postAndGetCollection(Object body,
Class<T> memberClass)
Posts request body and returns a collection of typed objects |
|
|
postAndGetCollection(Object collection,
Class<T1> memberClass,
Class<T2> responseClass)
Posts collection of typed objects and returns a collection of typed objects |
|
|
postCollection(Object collection,
Class<T> memberClass)
Posts a collection of typed objects |
|
|
postCollection(Object collection,
Class<T1> memberClass,
Class<T2> responseClass)
Posts a collection of typed objects |
|
javax.ws.rs.core.Response |
put(Object body)
Does HTTP PUT invocation |
|
WebClient |
query(String name,
Object... values)
Updates the current URI query parameters |
|
WebClient |
replaceHeader(String headerName,
String 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()
Resets 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)
|
|
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)
sets HTTP Content-Type header |
|
WebClient |
type(String type)
sets HTTP Content-Type header |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected WebClient(String baseAddress)
protected WebClient(URI baseAddress)
protected WebClient(ClientState state)
Method Detail |
---|
public static WebClient create(String baseAddress)
baseAddress
- baseAddresspublic static WebClient create(URI baseURI)
baseURI
- baseURIpublic static WebClient create(String baseURI, boolean threadSafe)
baseURI
- baseURIpublic static WebClient create(String baseAddress, List<?> providers)
baseURI
- baseURIproviders
- list of providerspublic static WebClient create(String baseAddress, List<?> providers, boolean threadSafe)
baseURI
- baseURIproviders
- list of providerspublic static WebClient create(String baseAddress, List<?> providers, String configLocation)
baseAddress
- baseAddressproviders
- list of providersconfigLocation
- classpath location of Spring configuration resource, can be null
public static WebClient create(String baseAddress, String configLocation)
baseAddress
- baseAddressconfigLocation
- classpath location of Spring configuration resource, can be null
public static WebClient create(String baseAddress, String username, String password, String configLocation)
baseAddress
- baseAddressusername
- usernamepassword
- passwordconfigLocation
- classpath location of Spring configuration resource, can be null
public 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 proxy)
proxy
- the proxy
public static ClientConfiguration getConfig(Object client)
client
- proxy or http-centric Client
public javax.ws.rs.core.Response invoke(String httpMethod, Object body)
httpMethod
- HTTP methodbody
- request body, can be null
public javax.ws.rs.core.Response post(Object body)
body
- request body, can be null
public javax.ws.rs.core.Response put(Object body)
body
- request body, can be null
public 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 values
public javax.ws.rs.core.Response form(Form form)
form
- form values
public <T> T invoke(String httpMethod, Object body, Class<T> responseClass)
httpMethod
- HTTP methodbody
- request body, can be nullresponseClass
- expected type of response object
public <T> T post(Object body, Class<T> responseClass)
body
- request body, can be nullresponseClass
- expected type of response object
public <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 class
public <T> javax.ws.rs.core.Response postCollection(Object collection, Class<T> memberClass)
collection
- request bodymemberClass
- type of collection member class
public <T1,T2> T2 postCollection(Object collection, Class<T1> memberClass, Class<T2> responseClass)
collection
- request bodymemberClass
- type of collection member classresponseClass
- expected type of response object
public <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 object
public <T> Collection<? extends T> postAndGetCollection(Object body, Class<T> memberClass)
body
- request body, can be nullmemberClass
- expected type of collection member class
public <T> Collection<? extends T> getCollection(Class<T> memberClass)
body
- request body, can be nullmemberClass
- expected type of collection member class
public <T> T get(Class<T> responseClass)
body
- request body, can be nullresponseClass
- expected type of response object
public WebClient path(Object path)
path
- new relative path segment
public WebClient path(String path, Object... values)
path
- new relative path segmentvalues
- template variable values
public WebClient query(String name, Object... values)
name
- query namevalues
- query values
public WebClient matrix(String name, Object... values)
name
- matrix namevalues
- matrix values
public WebClient fragment(String name)
name
- fragment name
public WebClient to(String newAddress, boolean forward)
newAddress
- new URIforward
- if true then currentURI will be based on baseURI
public WebClient back(boolean fast)
fast
- if true then goes back to baseURI otherwise to a previous path segment
public 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, String value)
headerName
- headerValuesvalue
- new values, null is equivalent to removing the header
public WebClient replaceQueryParam(String queryParam, Object... value)
queryString
- the new value, providing a null is
equivalent to calling resetQuery().
public WebClient type(javax.ws.rs.core.MediaType ct)
AbstractClient
type
in interface Client
type
in class AbstractClient
ct
- JAXRS MediaType representing Content-Type value
public WebClient type(String type)
AbstractClient
type
in interface Client
type
in class AbstractClient
type
- Content-Type value
public WebClient accept(javax.ws.rs.core.MediaType... types)
AbstractClient
accept
in interface Client
accept
in class AbstractClient
types
- list of JAXRS MediaTypes representing Accept header values
public WebClient accept(String... types)
AbstractClient
accept
in interface Client
accept
in class AbstractClient
types
- list of Accept header values
public WebClient language(String language)
AbstractClient
language
in interface Client
language
in class AbstractClient
language
- Content-Language header value
public WebClient acceptLanguage(String... languages)
AbstractClient
acceptLanguage
in interface Client
acceptLanguage
in class AbstractClient
languages
- list of Accept-Language header values
public WebClient encoding(String encoding)
AbstractClient
encoding
in interface Client
encoding
in class AbstractClient
encoding
- Content-Encoding header value
public WebClient acceptEncoding(String... encodings)
AbstractClient
acceptEncoding
in interface Client
acceptEncoding
in class AbstractClient
encodings
- list of Accept-Encoding header value
public WebClient match(javax.ws.rs.core.EntityTag tag, boolean ifNot)
AbstractClient
match
in interface Client
match
in class AbstractClient
tag
- ETag valueifNot
- if true then If-None-Match is set, If-Match otherwise
public WebClient modified(Date date, boolean ifNot)
AbstractClient
modified
in interface Client
modified
in class AbstractClient
date
- 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 otherwise
public WebClient cookie(javax.ws.rs.core.Cookie cookie)
AbstractClient
cookie
in interface Client
cookie
in class AbstractClient
cookie
- Cookie value
public WebClient header(String name, Object... values)
AbstractClient
header
in interface Client
header
in class AbstractClient
name
- header namevalues
- list of header values
public WebClient headers(javax.ws.rs.core.MultivaluedMap<String,String> map)
AbstractClient
headers
in interface Client
headers
in class AbstractClient
map
- headers
public WebClient reset()
AbstractClient
reset
in interface Client
reset
in class AbstractClient
protected javax.ws.rs.core.Response doInvoke(String httpMethod, Object body, Type inGenericType, Class<?> responseClass, Type outGenericType)
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 AbstractClient
Throwable
protected javax.ws.rs.core.Response doChainedInvocation(String httpMethod, javax.ws.rs.core.MultivaluedMap<String,String> headers, Object body, Type inGenericType, Class<?> responseClass, Type outGenericType, Exchange exchange, Map<String,Object> invContext)
protected javax.ws.rs.core.Response handleResponse(Message outMessage, Class<?> responseClass, Type genericType)
|
Apache CXF API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |