Hi all,
I'm pretty new to Scala and Play, so sorry if this is a dumb question. I'm trying to call a webservice and print out the entire response to the console but can't seem to figure it out. The response should be coming back as plain/text and all the examples I've seen are for examples to validate JSON that's been serialized back into an object.
My code (note this is inside a junit test):
val holder : WSRequestHolder = WS.url("http://mydomain.com/")
val futureResponse : Future[Response] = holder.get()
How exactly can I read the response back and print out the full text? I've seen ways use .map on the Response objects, but I'm still a bit confused.
One method i've tried, but not sure where to put the println statement. In this case, I know the webservice returns back a plain/text so I've used String with the Future
val futureResult: Future[String] = WS.url("http://mydomain/").get().map {
response =>
response.xml.text //should this be response.body? How can I print this out?
}
In java, I would normally use something like JaxRS to get the response as an InputStream, load it into a String, then print that out. I'm not sure if that's the best method in Scala, or if there's an easier way.
I feel like I've overlooked something simple. Any ideas?