我有一个从 java 后端代码中的服务调用获得的字符串值。当我得到一个字符串的值时,我想发出一个 post 请求并将字符串作为 url 编码的 base 64 字符串传递给端点。
问题是我得到一个 Socket Exception: Connection reset 错误。我正在使用 HttpClient 4.5.2 和 IBM Websphere (Rational Application Development) 更详细的错误是:
DefaultHttpClient org.apache.http.impl.client.DefaultRequestDirector tryConnect I/O Exception (java.net.SocketException) caught when connecting to {s} -> https://foo.bar:443: Connection reset
Java代码:
public ActionForward executeShowFormView(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
var stringResponse = serviceCall.getStringResponse();
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(serviceCall.getEndpointUrl());
StringEntity entity = new StringEntity("response=" + stringResponse, ContentType.APPLICATION_TYPE_URLENCODED);
post.setEntity(entity);
HttpResponse response1 = client.execute(post);
}
我能做些什么来修复错误?