1

我正在尝试修改代码,这是一个使用 apache httpcomponents 用 java 编写的异步服务器

我的客户端代码是这样的......

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);

我不确定这是否是最有效的方法。

4

0 回答 0