Package play.libs.ws

Interface WSClient

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
AhcWSClient

public interface WSClient extends Closeable
This is the WS Client interface for Java.

Most of the time you will access this through dependency injection, i.e.

 import jakarta.inject.Inject;
 import play.libs.ws.*;
 import java.util.concurrent.CompletionStage;

 public class MyService {
   @Inject WSClient ws;

    // ...
 }
 
 
Please see https://www.playframework.com/documentation/latest/JavaWS for more details.
  • Method Summary

    Modifier and Type
    Method
    Description
    play.api.libs.ws.WSClient
     
    void
    Closes this client, and releases underlying resources.
    The underlying implementation of the client, if any.
    url(String url)
    Returns a WSRequest object representing the URL.
  • Method Details

    • getUnderlying

      Object getUnderlying()
      The underlying implementation of the client, if any. You must cast the returned value to the type you want.
      Returns:
      the backing object.
    • asScala

      play.api.libs.ws.WSClient asScala()
      Returns:
      the Scala version for this WSClient.
    • url

      WSRequest url(String url)
      Returns a WSRequest object representing the URL. You can append additional properties on the WSRequest by chaining calls, and execute the request to return an asynchronous Promise<WSResponse>.
      Parameters:
      url - the URL to request
      Returns:
      the request
    • close

      void close() throws IOException
      Closes this client, and releases underlying resources.

      Use this for manually instantiated clients.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException