|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object play.PlayPlugin play.libs.WS
public class WS
Simple HTTP client to make webservices requests.
Get latest BBC World news as a RSS contentresponse = WS.GET("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml"); Document xmldoc = response.getXml(); // the real pain begins here...Search what Yahoo! thinks of google (starting from the 30th result).
response = WS.GET("http://search.yahoo.com/search?p=%s&pstart=1&b=%d", "Google killed me", 30 ); if( response.getStatus() == 200 ) { html = response.getString(); }
Nested Class Summary | |
---|---|
static class |
WS.FileParam
|
static class |
WS.HttpResponse
An HTTP response wrapper |
static class |
WS.WSRequest
|
Field Summary |
---|
Fields inherited from class play.PlayPlugin |
---|
index |
Constructor Summary | |
---|---|
WS()
|
Method Summary | |
---|---|
static void |
authenticate(org.apache.commons.httpclient.Credentials credentials,
org.apache.commons.httpclient.auth.AuthScope authScope)
|
static void |
authenticate(java.lang.String username,
java.lang.String password)
|
static void |
authenticate(java.lang.String username,
java.lang.String password,
java.lang.String url)
define client authentication for a server host provided credentials will be used during the request |
static WS.HttpResponse |
DELETE(java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String url)
Deprecated. Use WS.url().headers().delete() instead. |
static WS.HttpResponse |
DELETE(java.lang.String url)
Deprecated. Use WS.url().delete() instead. |
static java.lang.String |
encode(java.lang.String part)
URL-encode an UTF-8 string to be used as a query string parameter. |
static WS.HttpResponse |
GET(java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url(url).params().header().get() instead. |
static WS.HttpResponse |
GET(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params)
Deprecated. Use WS.url(url).params(params).get() instead. |
static WS.HttpResponse |
GET(java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url(url, params...).get() instead. |
static WS.HttpResponse |
HEAD(java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url().headers().params().head() instead. |
static WS.HttpResponse |
HEAD(java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url().head() instead. |
void |
invocationFinally()
Called at the end of the invocation. |
static WS.HttpResponse |
OPTIONS(java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url().headers().params().options() instead. |
static WS.HttpResponse |
OPTIONS(java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url().options() instead. |
static WS.HttpResponse |
POST(java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.String url,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Deprecated. Use WS.url(url).params().header().post() instead. |
static WS.HttpResponse |
POST(java.util.Map<java.lang.String,java.lang.Object> headers,
java.lang.String url,
java.lang.String body)
Deprecated. Use WS.url().headers().body().post() instead |
static WS.HttpResponse |
POST(java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String url,
java.io.File body)
Deprecated. Use WS.url(url).header().file().post() instead. |
static WS.HttpResponse |
POST(java.lang.String url,
java.io.File body)
Deprecated. Use WS.url(url).file().post() instead. |
static WS.HttpResponse |
POST(java.lang.String url,
java.io.File body,
java.lang.String mimeType)
Deprecated. Use WS.url(url).file().mimetype().post() instead. |
static WS.HttpResponse |
POST(java.lang.String url,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Deprecated. Use WS.url(url).params().post() instead. |
static WS.HttpResponse |
POST(java.lang.String url,
java.lang.String body,
java.lang.String mimeType)
Deprecated. Use WS.url(url).params().body().mimetype().post() instead. |
static WS.HttpResponse |
TRACE(java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url().headers().params().delete() instead. |
static WS.HttpResponse |
TRACE(java.lang.String url,
java.lang.Object... params)
Deprecated. Use WS.url().trace() instead. |
static WS.WSRequest |
url(java.lang.String url)
Build a WebService Request with the given URL. |
static WS.WSRequest |
url(java.lang.String url,
java.lang.String... params)
Build a WebService Request with the given URL. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WS()
Method Detail |
---|
public void invocationFinally()
PlayPlugin
invocationFinally
in class PlayPlugin
public static void authenticate(java.lang.String username, java.lang.String password, java.lang.String url)
username
- password
- url
- hostname url or null to authenticate on any hostspublic static void authenticate(java.lang.String username, java.lang.String password)
public static void authenticate(org.apache.commons.httpclient.Credentials credentials, org.apache.commons.httpclient.auth.AuthScope authScope)
public static WS.HttpResponse GET(java.lang.String url, java.lang.Object... params)
url
- an URL template with placeholders for parametersparams
- a variable list of parameters to be replaced in the template using the String.format(...) syntax
WS.HttpResponse
public static WS.HttpResponse GET(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> params)
url
- an URL template with placeholders for parametersparams
- a variable Map
WS.HttpResponse
public static WS.HttpResponse GET(java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.String url, java.lang.Object... params)
headers
- a map of headers to be appended to the request.url
- an template with %s,%d placeholders for parameters.params
- parameters to be replaced in the url template using the String.format(...) syntax
WS.HttpResponse
public static WS.HttpResponse POST(java.lang.String url, java.io.File body)
url
- resource URLbody
- content to be posted. content-type is guessed from the filename extension.
WS.HttpResponse
public static WS.HttpResponse POST(java.lang.String url, java.io.File body, java.lang.String mimeType)
url
- resource URLbody
- content to be postedmimeType
- the content type as a mimetype
WS.HttpResponse
public static WS.HttpResponse POST(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String url, java.io.File body)
headers
- a map of headers to be appended to the request.url
- resource URLbody
- content to be posted. content-type is guessed from the filename extension.
WS.HttpResponse
public static WS.HttpResponse POST(java.lang.String url, java.util.Map<java.lang.String,java.lang.Object> parameters)
url
- the request URLparameters
- the parameters to be posted
WS.HttpResponse
public static WS.HttpResponse POST(java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.String url, java.util.Map<java.lang.String,java.lang.Object> parameters)
headers
- the request HTTP headersurl
- the request URLparameters
- the parameters to be posted
WS.HttpResponse
public static WS.HttpResponse POST(java.lang.String url, java.lang.String body, java.lang.String mimeType)
url
- resource URLbody
- text content to be posted "as is", with not encodingmimeType
- the request content-type
WS.HttpResponse
public static WS.HttpResponse POST(java.util.Map<java.lang.String,java.lang.Object> headers, java.lang.String url, java.lang.String body)
headers
- extra request headersurl
- resource URLbody
- text content to be posted "as is"
WS.HttpResponse
public static WS.HttpResponse DELETE(java.lang.String url)
url
- resource URL
WS.HttpResponse
public static WS.HttpResponse DELETE(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String url)
headers
- extra request headersurl
- resource URLparams
- query parameters
WS.HttpResponse
public static WS.HttpResponse HEAD(java.lang.String url, java.lang.Object... params)
url
- resource URLparams
- query parameters
WS.HttpResponse
public static WS.HttpResponse HEAD(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String url, java.lang.Object... params)
headers
- extra request headersurl
- resource URLparams
- query parameters
WS.HttpResponse
public static WS.HttpResponse TRACE(java.lang.String url, java.lang.Object... params)
url
- resource URLparams
- query parameters
WS.HttpResponse
public static WS.HttpResponse TRACE(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String url, java.lang.Object... params)
headers
- extra request headersurl
- resource URLparams
- query parameters
public static WS.HttpResponse OPTIONS(java.lang.String url, java.lang.Object... params)
url
- resource URLparams
- query parameters
public static WS.HttpResponse OPTIONS(java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String url, java.lang.Object... params)
headers
- extra request headersurl
- resource URLparams
- query parameters
public static java.lang.String encode(java.lang.String part)
part
- string to encode
public static WS.WSRequest url(java.lang.String url)
url
- of the request
public static WS.WSRequest url(java.lang.String url, java.lang.String... params)
url
- to format using the given params.params
- the params passed to format the URL.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |