play.libs
类 WS

java.lang.Object
  继承者 play.PlayPlugin
      继承者 play.libs.WS
所有已实现的接口:
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();
    }
 


嵌套类摘要
static class WS.FileParam
           
static class WS.HttpResponse
          An HTTP response wrapper
static class WS.Scheme
           
static interface WS.WSImpl
           
static class WS.WSRequest
           
static class WS.WSWithEncoding
          Internal class exposing all the methods previously exposed by WS.
 
字段摘要
 
从类 play.PlayPlugin 继承的字段
index
 
构造方法摘要
WS()
           
 
方法摘要
static java.lang.String encode(java.lang.String part)
          URL-encode a string to be used as a query string parameter.
 void onApplicationStart()
          Called at application start (and at each reloading) Time to start stateful things.
 void onApplicationStop()
          Called at application stop (and before each reloading) Time to shutdown stateful things.
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.
static WS.WSWithEncoding withEncoding(java.lang.String encoding)
          Use thos method to get an instance to WS with diferent encoding
 
从类 play.PlayPlugin 继承的方法
addMimeTypes, addTemplateExtensions, afterActionInvocation, afterApplicationStart, afterFixtureLoad, afterInvocation, beforeActionInvocation, beforeDetectingChanges, beforeInvocation, bind, bind, bind, bindBean, compareTo, compileAll, compileSources, detectChange, detectClassesChange, enhance, getJsonStatus, getMessage, getStatus, invocationFinally, loadTemplate, modelFactory, onActionInvocationResult, onApplicationReady, onClassesChange, onConfigurationRead, onEvent, onInvocationException, onInvocationSuccess, onLoad, onRequestRouting, onRoutesLoaded, onTemplateCompilation, overrideTemplateSource, postEvent, rawInvocation, routeRequest, runTest, serveStatic, unBind, willBeValidated
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

WS

public WS()
方法详细信息

withEncoding

public static WS.WSWithEncoding withEncoding(java.lang.String encoding)
Use thos method to get an instance to WS with diferent encoding

参数:
encoding - the encoding to use in the communication
返回:
a new instance of WS with specified encoding

onApplicationStop

public void onApplicationStop()
从类 PlayPlugin 复制的描述
Called at application stop (and before each reloading) Time to shutdown stateful things.

覆盖:
PlayPlugin 中的 onApplicationStop

onApplicationStart

public void onApplicationStart()
从类 PlayPlugin 复制的描述
Called at application start (and at each reloading) Time to start stateful things.

覆盖:
PlayPlugin 中的 onApplicationStart

encode

public static java.lang.String encode(java.lang.String part)
URL-encode a string to be used as a query string parameter.

参数:
part - string to encode
返回:
url-encoded string

url

public static WS.WSRequest url(java.lang.String url)
Build a WebService Request with the given URL. This object support chaining style programming for adding params, file, headers to requests.

参数:
url - of the request
返回:
a WSRequest on which you can add params, file headers using a chaining style programming.

url

public static WS.WSRequest url(java.lang.String url,
                               java.lang.String... params)
Build a WebService Request with the given URL. This constructor will format url using params passed in arguments. This object support chaining style programming for adding params, file, headers to requests.

参数:
url - to format using the given params.
params - the params passed to format the URL.
返回:
a WSRequest on which you can add params, file headers using a chaining style programming.


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly