Re: [scalaxb] Why do I have to use await on the Futures

25 views
Skip to first unread message

eugene yokota

unread,
May 5, 2017, 7:10:02 PM5/5/17
to scalaxb
Hi,

Because freponse represents a Future value, which basically means it's running on another thread in this case.
That thread is owned by Dispatch, which is part of val service.
If val service goes out of scope before the response comes back you won't see the println.

What you should do is create an object that can hold on to val service during the lifetime of your app.
Then you should see your future eventually.

-eugene



On Fri, May 5, 2017 at 5:20 PM, Kha La <khangn...@gmail.com> wrote:
Hi,

I am refering to this guide: http://scalaxb.org/wsdl-support

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
import scala.concurrent.duration._
 
val service = (new stockquote.StockQuoteSoap12Bindings with
  scalaxb
.SoapClientsAsync with
  scalaxb
.DispatchHttpClientsAsync {}).service
val fresponse = service.getQuote(Some("GOOG"))
val response = Await.result(fresponse, 5 seconds)
println
(response)

Why do I have to use Await? I've tried to use map instead, but it just won't be called.

val fresponse = service.getQuote(Some("GOOG"))
fresponse
.map { response => println(response) }


--
You received this message because you are subscribed to the Google Groups "scalaxb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaxb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages