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}

これについての提案、ポインタ、またはヒントは大歓迎です。

- 編集 -

多くの検索の後、1つの解決策が見つかりました

HttpEntity entity1 = ((HttpEntityEnclosingRequest)request).getEntity();
        String str = EntityUtils.toString(entity1);

これが最も効率的な方法であるかどうかはわかりません。

4

0 に答える 0