【发布时间】:2015-12-01 08:21:05
【问题描述】:
如何让 HttpClientResponse 返回 InputStream 而不是 vertx.rx.Buffer?
HttpClientRequest req = client.requestAbs(HttpMethod.POST, endpointUrl);
req.putHeader("Content-Type", "text/xml; charset=utf-8").
putHeader("SOAPAction", "http://192.168.0.170/TT/BookingAPI/Search");
req.toObservable().flatMap(resp -> {
if (resp.statusCode() != HttpStatus.SC_OK) {
throw new RuntimeException("Wrong status code " + resp.statusCode());
}
return resp.toObservable();
}).subscribe(new Subscriber<InputStream>() {
public void onNext(InputStream stream) {
// 默认实现为Buffer,需要获取InputStream传递给StaxReader。 } 公共无效 onError(Throwable e) { }
public void onCompleted() {
System.out.println("Start at :"+ st +" End at :"+ System.currentTimeMillis()+"Time taken: " + (System.currentTimeMillis() - st));
}
});
req.end(request);
}
【问题讨论】: