を使用して、Web サービスにリクエストHttpClient
を送信し、SOAP
データを照会しています。一部の Web サービス パラメータでは、Web サービスの実行に 5 分以上かかり、5 分後にjava.net.SocketException: Connection reset
.
接続が 5 分以上アイドル状態になり、ファイアウォールが接続を制限したためにエラーが発生したと思います。
http post リクエストまたは接続を維持するためのキープアライブ パッケージを送信する方法はありますか? (可能であれば、クライアント側のソリューションが必要です)
Google でHttpClient keep-alive
検索すると、接続の再利用に関する多くのトピックが見つかります。私の場合、応答があるまで接続を維持したいだけです。
SOAP リクエストを実行するメソッド:
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;
}
現在、HttpClient v3.1 が使用されています。