我正在尝试使用通过 xmlhttprequest 响应发送的 xml 文档从 Web 服务器(使用 javascript)打开浏览器窗口。该应用程序使用 javascript,因此这里没有使用 java 1.5。xmlhttp 帖子的代码是这样的:
String strSoap = "<?xml version='1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<soap:Body>" +
xml_body
"</soap:Body>" +
"</soap:Envelope>";
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
connection.setRequestProperty("SoapAction", some_action);
connection.setRequestProperty("Man", "POST url HTTP/1.1");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setAllowUserInteraction(true);
connection.setFollowRedirects(true);
java.io.DataOutputStream printout = new java.io.DataOutputStream (connection.getOutputStream());
printout.writeBytes(strSoap);
printout.flush();
printout.close();
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(connection.getInputStream()));
另一个可能性是从客户端发出 xmlhttprequest,哪个是更好的选择?