(Since version 2.3.0) Please use play.api.libs.ws.WSResponse
(Since version 2.3.0) Please use play.api.libs.ws.WSRequest
(Since version 2.3.0) Please use play.api.libs.ws.WSRequestHolder
Retrieves or creates underlying HTTP client.
Retrieves or creates underlying HTTP client. Note that due to the Plugin architecture, an implicit application must be in scope. Most of the time you will want the current app:
import play.api.Play.current val client = WS.client
Prepares a new request using an implicit client.
Prepares a new request using an implicit client. The client must be in scope and configured, i.e.
implicit val sslClient = new play.api.libs.ws.ning.NingWSClient(sslBuilder.build()) WS.clientUrl("http://example.com/feed")
the URL to request
the client to use to make the request.
Prepares a new request using a provided magnet.
Prepares a new request using a provided magnet. This method gives you the ability to create your own URL implementations at the cost of some complexity.
object PairMagnet { implicit def fromPair(pair: Pair[WSClient, java.net.URL]) = new WSRequestHolderMagnet { def apply(): WSRequestHolder = { val (client, netUrl) = pair client.url(netUrl.toString) } } } import scala.language.implicitConversions val client = WS.client val exampleURL = new java.net.URL("http://example.com") WS.url(client -> exampleURL).get()
a magnet pattern.
Prepares a new request using an implicit application.
Prepares a new request using an implicit application. This creates a default client, which you can then use to construct a request.
import play.api.Play.current WS.url("http://localhost/").get()
the URL to request
the implicit application to use.
Asynchronous API to to query web services, as an http client.
Usage example:
When greater flexibility is needed, you can also create clients explicitly and pass them into WS:
Or call the client directly:
Note that the resolution of URL is done through the magnet pattern defined in
WSRequestHolderMagnet
.The value returned is a
Future[WSResponse]
, and you should use Play's asynchronous mechanisms to use this response.