我想将一些 xml 数据发送到服务器,然后在屏幕上打印我收到的 xml。
到目前为止,我所拥有的是:
<script type="text/javascript">
function authIHC() {
var req = new XMLHttpRequest();
var xml_request;
var username = "user";
var password = "password";
xml_request = "<?xml version='1.0' encoding='UTF-8'?>\n";
xml_request = xml_request + "<SOAP-ENV:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n";
xml_request = xml_request + "<SOAP-ENV:Body>\n";
xml_request = xml_request + "<ns1:authenticate1 xmlns:ns1=\"utcs\" xsi:type=\"ns1:WSAuthenticationData\">\n";
xml_request = xml_request + "<ns1:password xsi:type=\"xsd:string\">" + password + "</ns1:password>\n";
xml_request = xml_request + "<ns1:username xsi:type=\"xsd:string\">" + username + "</ns1:username>\n";
xml_request = xml_request + "<ns1:application xsi:type=\"xsd:string\">treeview</ns1:application>\n";
xml_request = xml_request + "</ns1:authenticate1>\n";
xml_request = xml_request + "</SOAP-ENV:Body>\n";
xml_request = xml_request + "</SOAP-ENV:Envelope>\n";
req.onreadystatechange=function()
{
if (req.readyState==4)
{
alert(req.statusText);
}
else {alert ("nothing");}
}
req.open('PUT', 'https://10.0.0.254/ws/AuthenticationService', true);
req.setRequestHeader('Content-Type', 'text/xml');
req.send(xml_request);
}
</script>
问题是我从来没有得到任何东西,它总是打印在一个盒子里:什么都没有。
能否请你帮忙?