Search code examples
web-servicesrestjava-6jersey-client

Rest full web service executed twice for one call in java


I am calling a Restful web service call using Jersey client API 1.19. As in client side I have called web service once, but in turn the called web service is executing twice.

Is there any property to be set while calling in client side or while sending from service side

If not is there any other way to track the issue

as I had gone through WCF method called twice but It didn't helped me

My code is as follows

 Client client = Client.create();

    WebResource webResource = client.resource(baseuri);
           webResource.method(POST);
    ClientResponse response = webResource.accept("application/xml")
            .type("application/xml").post(ClientResponse.class);

Solution

  • Here I was getting two response

    Because I used
    webResource.method("POST");

    i.e when I set method webResource then service was invoked by webResource and even with clientResponse.

    Eventually I was getting two response so after removing above code, then service called only for clientResponse call and not for webResponse