我正在尝试修改this代码,这是一个用java编写的异步服务器,使用apache httpcomponents
我的客户端代码是这样的......
HttpPost httpPost= new HttpPost("http://localhost:9090");
HttpEntity se= new StringEntity(XMLSTRING);
httpPost.setEntity(se);
我的服务器句柄是这样的
public void handle(
final HttpRequest request,
final HttpAsyncExchange httpexchange,
final HttpContext context) throws HttpException, IOException {
HttpResponse response = httpexchange.getResponse();
handleInternal(request, response, context);
httpexchange.submitResponse(new BasicAsyncResponseProducer(response));
}
private void handleInternal(
final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException { need to get xml from response}
欢迎任何关于如何解决这个问题的建议,指针或提示。
- 编辑 -
经过多次搜索后发现了一个解决方案
HttpEntity entity1 = ((HttpEntityEnclosingRequest)request).getEntity();
String str = EntityUtils.toString(entity1);
我不确定这是否是最有效的方法。