Creating a GET request for a web service from playframework 2.0

I am trying to call a web service from a playback frame, and I think I am doing it wrong. I have an example call http://www.myweather2.com/developer/forecast.ashx?uac=eDKGlpcBQN&query=52.6%2C-4.4&output=xml

An excerpt from what I am trying to reproduce is as follows:

val response = WS.url("http://www.myweather2.com/developer/forecast.ashx?uac=eDKGlpcBQN&query=52.6%2C-4.4&output=xml").get.get()
val body = response.getBody

When I call it, the body consists of "useraccount does not exist." When I just put this URL into the browser, I get the answer I'm looking for. What am I doing wrong here?

+5
source share
3 answers

- WS . import play.api.libs.ws.WS, . ,

+9

, "useraccount ", :

  val promise = WS.url("http://www.myweather2.com/developer/forecast.ashx?uac=eDKGlpcBQN&query=52.6%2C-4.4&output=xml").get()
  val body = promise.value.get.body

: .

, \n \r ?

+2

, , , - .

GET WS.url( "http://..." ).setQueryParameter(, )

:

val promise = WS.url("http://www.myweather2.com/developer/forecast.ashx").setQueryParameter("uac", "eDKGlpcBQN").setQueryParameter("query", "52.6%2C-4.4").setQueryParameter("output", "xml").get()

, .

+2

All Articles