|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectplay.PlayPlugin
play.libs.WS
public class WS
Simple HTTP client to make webservices requests.
Get latest BBC World news as a RSS content
response = 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(String username,
String password)
|
static void |
authenticate(String username,
String password,
String url)
define client authentication for a server host provided credentials will be used during the request |
static WS.HttpResponse |
DELETE(Map<String,String> headers,
String url)
Deprecated. Use WS.url().headers().delete() instead. |
static WS.HttpResponse |
DELETE(String url)
Deprecated. Use WS.url().delete() instead. |
static String |
encode(String part)
URL-encode an UTF-8 string to be used as a query string parameter. |
static WS.HttpResponse |
GET(Map<String,Object> headers,
String url,
Object... params)
Deprecated. Use WS.url(url).params().header().get() instead. |
static WS.HttpResponse |
GET(String url,
Map<String,String> params)
Deprecated. Use WS.url(url).params(params).get() instead. |
static WS.HttpResponse |
GET(String url,
Object... params)
Deprecated. Use WS.url(url, params...).get() instead. |
static WS.HttpResponse |
HEAD(Map<String,String> headers,
String url,
Object... params)
Deprecated. Use WS.url().headers().params().head() instead. |
static WS.HttpResponse |
HEAD(String url,
Object... params)
Deprecated. Use WS.url().head() instead. |
void |
invocationFinally()
Called at the end of the invocation. |
static WS.HttpResponse |
OPTIONS(Map<String,String> headers,
String url,
Object... params)
Deprecated. Use WS.url().headers().params().options() instead. |
static WS.HttpResponse |
OPTIONS(String url,
Object... params)
Deprecated. Use WS.url().options() instead. |
static WS.HttpResponse |
POST(Map<String,Object> headers,
String url,
Map<String,Object> parameters)
Deprecated. Use WS.url(url).params().header().post() instead. |
static WS.HttpResponse |
POST(Map<String,Object> headers,
String url,
String body)
Deprecated. Use WS.url().headers().body().post() instead |
static WS.HttpResponse |
POST(Map<String,String> headers,
String url,
File body)
Deprecated. Use WS.url(url).header().file().post() instead. |
static WS.HttpResponse |
POST(String url,
File body)
Deprecated. Use WS.url(url).file().post() instead. |
static WS.HttpResponse |
POST(String url,
File body,
String mimeType)
Deprecated. Use WS.url(url).file().mimetype().post() instead. |
static WS.HttpResponse |
POST(String url,
Map<String,Object> parameters)
Deprecated. Use WS.url(url).params().post() instead. |
static WS.HttpResponse |
POST(String url,
String body,
String mimeType)
Deprecated. Use WS.url(url).params().body().mimetype().post() instead. |
static WS.HttpResponse |
TRACE(Map<String,String> headers,
String url,
Object... params)
Deprecated. Use WS.url().headers().params().delete() instead. |
static WS.HttpResponse |
TRACE(String url,
Object... params)
Deprecated. Use WS.url().trace() instead. |
static WS.WSRequest |
url(String url)
Build a WebService Request with the given URL. |
static WS.WSRequest |
url(String url,
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(String username,
String password,
String url)
username - password - url - hostname url or null to authenticate on any hosts
public static void authenticate(String username,
String password)
public static void authenticate(org.apache.commons.httpclient.Credentials credentials,
org.apache.commons.httpclient.auth.AuthScope authScope)
public static WS.HttpResponse GET(String url,
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(String url,
Map<String,String> params)
url - an URL template with placeholders for parametersparams - a variable Map
WS.HttpResponse
public static WS.HttpResponse GET(Map<String,Object> headers,
String url,
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(String url,
File body)
url - resource URLbody - content to be posted. content-type is guessed from the filename extension.
WS.HttpResponse
public static WS.HttpResponse POST(String url,
File body,
String mimeType)
url - resource URLbody - content to be postedmimeType - the content type as a mimetype
WS.HttpResponse
public static WS.HttpResponse POST(Map<String,String> headers,
String url,
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(String url,
Map<String,Object> parameters)
url - the request URLparameters - the parameters to be posted
WS.HttpResponse
public static WS.HttpResponse POST(Map<String,Object> headers,
String url,
Map<String,Object> parameters)
headers - the request HTTP headersurl - the request URLparameters - the parameters to be posted
WS.HttpResponse
public static WS.HttpResponse POST(String url,
String body,
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(Map<String,Object> headers,
String url,
String body)
headers - extra request headersurl - resource URLbody - text content to be posted "as is"
WS.HttpResponsepublic static WS.HttpResponse DELETE(String url)
url - resource URL
WS.HttpResponse
public static WS.HttpResponse DELETE(Map<String,String> headers,
String url)
headers - extra request headersurl - resource URL
WS.HttpResponse
public static WS.HttpResponse HEAD(String url,
Object... params)
url - resource URLparams - query parameters
WS.HttpResponse
public static WS.HttpResponse HEAD(Map<String,String> headers,
String url,
Object... params)
headers - extra request headersurl - resource URLparams - query parameters
WS.HttpResponse
public static WS.HttpResponse TRACE(String url,
Object... params)
url - resource URLparams - query parameters
WS.HttpResponse
public static WS.HttpResponse TRACE(Map<String,String> headers,
String url,
Object... params)
headers - extra request headersurl - resource URLparams - query parameters
public static WS.HttpResponse OPTIONS(String url,
Object... params)
url - resource URLparams - query parameters
public static WS.HttpResponse OPTIONS(Map<String,String> headers,
String url,
Object... params)
headers - extra request headersurl - resource URLparams - query parameters
public static String encode(String part)
part - string to encode
public static WS.WSRequest url(String url)
url - of the request
public static WS.WSRequest url(String url,
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 | |||||||||