I'm using a HttpClient
to send a SOAP
request to an webservice to query some data. For some webservice parameters the execution of the webservice takes longer than 5 minutes and after 5 minutes I get an java.net.SocketException: Connection reset
.
I think that the error occures because the connection idles for more than 5 minutes and then a firewall caps the connection.
Is there a way to send a keep-alive package for a http post request or something to keep the connection alive? (I need a client-side solution if possible)
If you google for HttpClient keep-alive
you find a lot of topics regarding reusing a connection. In my case I only want to keep the connection alive until I get a response.
Method to execute the SOAP request:
def executeSOAPRequest(String url, String content, String soapAction, Integer timeout) {
def retVal = new SoapResponse();
PostMethod post = new PostMethod(url);
RequestEntity entity = new StringRequestEntity(content,"ISO-8859-1","ISO-8859-1");
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", soapAction);
HttpClient httpclient = new HttpClient()
httpclient.setTimeout(timeout)
try {
retVal.httpResponse = httpclient.executeMethod(post);
retVal.httpResponseBody = post.getResponseBodyAsString();
} catch(Exception e){
... exception handling ...
} finally {
... finally stuff ...
}
return retVal;
}
Currently the HttpClient v3.1 is used.