通过javascript 405方法调用SOAP服务不允许错误。

时间:2014-03-20 09:15:20

标签: javascript web-services soap

我已经在javascript中实现了 SOAP 服务调用,它运行正常,我在Android或iOS中通过手机间隙执行它时得到响应但是当我尝试在浏览器中执行它时我收到的错误是405。

  

无法加载资源:服务器响应状态为405(方法不允许)

     

无法加载资源:无效的HTTP状态代码405

     

XMLHttpRequest无法加载'serviceurl'。无效的HTTP状态代码405

实施 SOAP 服务调用的代码如下:

<script type="text/javascript">
        var xmlhttp = new XMLHttpRequest();
        var IDcardNo = 'IHL1167618';
        //function for executing the soap service c
        function soap() {
            //creating headers
            xmlhttp.open('POST', 'http://123.176.47.52/SOAPservice/Service.asmx', true);
            xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=\"utf-8\""); 
            xmlhttp.setRequestHeader("POST","/SOAPservice/Service.asmx HTTP/1.1");
            xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/GetPSDetails");

            xmlhttp.onreadystatechange= handler;  
            alert("set request header completed");  

            //SOAP Request XML format
            var sr =
                '<?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>'+
                        '<GetPSDetails xmlns="http://tempuri.org/">'+
                            '<IDCARDNO>' + IDcardNo + '</IDCARDNO>'+
                        '</GetPSDetails>'+
                    '</soap:Body>'+
                '</soap:Envelope>';
            xmlhttp.send(sr);
        }
        function handler() {  
            if(xmlhttp.readyState ==4  && xmlhttp.status==200) {  
                //status of the request
             alert("readystate:"+xmlhttp.readyState+"status:"+xmlhttp.status);
                //response formt the server
             alert(xmlhttp.responseText);
         }  
    }  
    </script> 

请帮助我,找到我在哪里犯错误?

0 个答案:

没有答案