我如何将 xml 发布到 https web 服务并获取 xml 响应... 要求是这样的..
Web 服务接受参数有效负载,我们可以在其中传递 xml,并且我将获取响应 xml。
网址如下所示: https://servername/aaa/bbb/us/ws.do ?
最佳答案
private static final String CERT_FILE_LOC = "/aaa/bbb/ccffdd.jks";
System.setProperty("javax.net.ssl.trustStore", CERT_FILE_LOC);
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
URL url = new URL(inputUrl);
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setDoOutput(true);
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
responseXml=responseXml+line;
}
in.close();
System.out.println("responseXml");
关于java - 如何在java中通过https web服务发布xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3627133/