1

I am trying to modify this code, which is an asynchronous server written in java using apache httpcomponents

My client code is something like this...

HttpPost httpPost= new HttpPost("http://localhost:9090");
HttpEntity se= new StringEntity(XMLSTRING);
httpPost.setEntity(se);

My server handle is something like this

     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}

Any suggestions, pointer or hints on how to go about this is welcome.

--edit--

Well after much searching found one solution

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

I am not sure if this is the most efficient way to go about it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.