如何使 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);
}