在我当前的项目中,我必须实现一个客户端来调用 SOAP 服务。我选择使用 ScalaXB 来从 WSDL 文件生成客户端及其模型。我设法编译了项目并生成了模型,但我一直在进行 HTTP 调用。
这是我的DispatchHttpClientsAsync
特点,问题是我如何才能真正进行 Http 调用?
trait DispatchHttpClientsAsync extends HttpClientsAsync {
lazy val httpClient = new DispatchHttpClient {}
// https://github.com/AsyncHttpClient/async-http-client/blob/1.9.x/src/main/java/com/ning/http/client/AsyncHttpClientConfigDefaults.java
def requestTimeout: Duration = 60.seconds
def connectionTimeout: Duration = 5.seconds
trait DispatchHttpClient extends HttpClient {
import dispatch._
// Keep it lazy. See https://github.com/eed3si9n/scalaxb/pull/279
lazy val http = Http.configure(_.
setRequestTimeout(requestTimeout.toMillis.toInt).
setConnectTimeout(connectionTimeout.toMillis.toInt))
def request(in: String, address: java.net.URI, headers: Map[String, String])(implicit ec: ExecutionContext): Future[String] = {
val req = url(address.toString).setBodyEncoding("UTF-8") <:< headers << in
http(req > as.String)
}
}
}