我正在尝试进行SOAP Web服务自动化,我在执行时发现了一个异常。当我试图运行/调试时抛出java.io.FileNotFoundException,我还发现我收到的响应代码是404.我使用JKS格式密钥库来保证安全。
代码:
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());
}
当我尝试执行httpConnection.getInputStream()时,它会抛出java.io.FileNotFoundException。我作为参数发送的URL也是有效的。这个例外可能是什么原因?
答案 0 :(得分:0)
代码中没有错,唯一要检查的是它是Http还是Https连接。最后,我发现它是SAAJ Request,它与SAAJ Code一起使用