Package play.libs
Class WS
- java.lang.Object
-
- play.PlayPlugin
-
- play.libs.WS
-
- All Implemented Interfaces:
java.lang.Comparable<PlayPlugin>
public class WS extends PlayPlugin
Simple HTTP client to make webservices requests.Get latest BBC World news as a RSS content
HttpResponse response = WS.url("http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml").get(); Document xmldoc = response.getXml(); // the real pain begins here...Search what Yahoo! thinks of google (starting from the 30th result).
HttpResponse response = WS.url("http://search.yahoo.com/search?p=%s&pstart=1&b=%s", "Google killed me", "30").get(); if (response.getStatus() == 200) { html = response.getString(); }
-
-
Field Summary
-
Fields inherited from class play.PlayPlugin
index
-
-
Constructor Summary
Constructors Constructor Description WS()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidonApplicationStart()Called at application start (and at each reloading) Time to start stateful things.voidonApplicationStop()Called at application stop (and before each reloading) Time to shutdown stateful things.static WSRequesturl(java.lang.String url)Deprecated.Using this static method make it hard to test.-
Methods inherited from class play.PlayPlugin
afterActionInvocation, afterApplicationStart, afterInvocation, beforeActionInvocation, beforeInvocation, bind, compareTo, detectChange, disable, getJsonStatus, getMessage, getStatus, isEnabled, loadTemplate, onActionInvocationException, onActionInvocationFinally, onActionInvocationResult, onActionInvocationResult, onConfigurationRead, onInvocationSuccess, onJobInvocationException, onJobInvocationFinally, onLoad, rawInvocation, routeRequest
-
-
-
-
Method Detail
-
onApplicationStop
public void onApplicationStop()
Description copied from class:PlayPluginCalled at application stop (and before each reloading) Time to shutdown stateful things.- Overrides:
onApplicationStopin classPlayPlugin
-
onApplicationStart
public void onApplicationStart()
Description copied from class:PlayPluginCalled at application start (and at each reloading) Time to start stateful things.- Overrides:
onApplicationStartin classPlayPlugin
-
url
@Deprecated public static WSRequest url(java.lang.String url)
Deprecated.Using this static method make it hard to test. A better option is to @Inject WSClient instance to your class.Build a WebService Request with the given URL. This object support chaining style programming for adding params, file, headers to requests.- Parameters:
url- of the request- Returns:
- a WSRequest on which you can add params, file headers using a chaining style programming.
-
-