Advertisement
Guest User

Calling Web Service

a guest
Mar 6th, 2014
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.60 KB | None | 0 0
  1. class callingWS {
  2.  
  3.   def callWSMethod(name: String, filename: String) = {
  4.  
  5.     val data = Json.obj(
  6.       "input_sent" -> name,
  7.       "Filename" -> filename)
  8.  
  9.     val holder: Future[Response] = WS.url("http://0.0.0.0:8015/endpoint/").withHeaders("Content-Type" -> "application/json").post(data)
  10.     implicit val context = scala.concurrent.ExecutionContext.Implicits.global
  11.  
  12.     implicit val timeout = Timeout(100000 milliseconds)
  13.  
  14.     val future = holder.map { response =>
  15.  
  16.       (response.json \ "result")
  17.  
  18.     }
  19.  
  20.     val result = Await.result(future, timeout.duration)
  21.     result
  22.  
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement