In this recipe, we will explore the Play WS API to consume external web services from a Play 2 web application. As web application requirements evolve, we become more dependent on external data services for data such as foreign exchange rates, real-time weather data, and so on. The Play WS library provides us with APIs to be able to interface with external web services.
For Java, we need to perform the following steps:
foo_javaapplication with Hot-Reloading enabled:
playWsas a project dependency in
libraryDependencies ++= Seq( javaWs )
foo_java/app/controllers/WebClient.javaand add the following content:
package controllers; import ...