简体   繁体   English

无法接收SOAP响应,因此从HttpURLConnection抛出java.io.FileNotFoundException

[英]Unable to receive SOAP Response, java.io.FileNotFoundException is thrown from HttpURLConnection

I am trying to do SOAP Web Service Automation, I figured out an Exception while executing. 我正在尝试进行SOAP Web服务自动化,我在执行时发现了一个异常。 java.io.FileNotFoundException was thrown when i tried to run/debug, I also found that the response code that I received was 404. I am using a JKS format keystore for security. 尝试运行/调试时引发了java.io.FileNotFoundException,我还发现收到的响应代码是404。为了安全起见,我使用的是JKS格式的密钥库。

Code: 码:

HttpURLConnection httpConnection = null;
String strResponse = null;
java.net.URL url = new URL(strURL);
if (url.getProtocol().equalsIgnoreCase("http")) {
httpConnection = (HttpURLConnection) url.openConnection();      
}
httpConnection.setDoOutput(true);
httpConnection.setDoInput(true);
httpConnection.setRequestMethod("POST");
OutputStreamWriter writer = new OutputStreamWriter(httpConnection.getOutputStream());
writer.write(wsRequestString);
writer.close();
System.out.println(httpConnection.getResponseCode());
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println(httpConnection.getInputStream());
}

When I am trying to execute httpConnection.getInputStream(), it throws java.io.FileNotFoundException. 当我尝试执行httpConnection.getInputStream()时,它将引发java.io.FileNotFoundException。 Also the URL I am sending as parameter is also a valid one. 另外,我作为参数发送的URL也是有效的。 what could be the possible reason for this exception? 发生此异常的可能原因是什么?

There is no wrong in the code, only thing was to checked was whether it was a Http or Https connection. 代码没有错误,只检查了它是Http还是Https连接。 Finally, I found it to be SAAJ Request, it worked with SAAJ Code 最后,我发现它是SAAJ Request,它与SAAJ Code一起使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM