Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jquery.ajax()创建soap请求_Javascript_Jquery_Ajax_Web Services_Soap - Fatal编程技术网

Javascript 使用jquery.ajax()创建soap请求

Javascript 使用jquery.ajax()创建soap请求,javascript,jquery,ajax,web-services,soap,Javascript,Jquery,Ajax,Web Services,Soap,我希望创建特定函数的soap请求。我的代码如下,不调用该函数,这将返回整个wsdl xml文件作为响应。请检查代码,如果我犯了任何错误 var soapMessage='<?xml version="1.0" encoding="utf-8"?>\n'; soapMessage+='<SOAP-ENV:Envelope'; soapMessage+=' SOAP-ENV:encodingStyle="htt

我希望创建特定函数的soap请求。我的代码如下,不调用该函数,这将返回整个wsdl xml文件作为响应。请检查代码,如果我犯了任何错误

var soapMessage='<?xml version="1.0" encoding="utf-8"?>\n';
                soapMessage+='<SOAP-ENV:Envelope';
                    soapMessage+=' SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"';
                    soapMessage+=' xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"';
                    soapMessage+=' xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"';
                    soapMessage+=' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"';
                    soapMessage+=' xmlns:xsd="http://www.w3.org/1999/XMLSchema"';
                    soapMessage+='>\n';
                soapMessage+='<SOAP-ENV:Body>\n';
                soapMessage+='<ns1:userdetail xmlns:ns1="urn:xmds" SOAP-ENC:root="1">\n';
                    soapMessage+='<username xsi:type="xsd:string">1</username>\n';
                    soapMessage+='<gender xsi:type="xsd:string">1</gender>\n';
                soapMessage+='</ns1:userdetail>\n';
            soapMessage+='</SOAP-ENV:Body>\n';
            soapMessage+='</SOAP-ENV:Envelope>';


    $.ajax({
                       url: "http://myIP/server/xmds.php?wsdl",
                       type: "POST",
                      beforeSend: function (xhr){
                       //xhr.setRequestHeader("SOAPAction", "urn:xmds#RestoreDisplayIfAny");
                       //xhr.setRequestHeader("host", "http://MYIP/server/");
                       //xhr.setRequestHeader("SOAPTarget","http://MYIP/server/xmds.php?wsdl");
                        xhr.setRequestHeader("SOAPAction","http://MYIP/server/");
                       xhr.setRequestHeader("Access-Control-Allow-Headers", "*");
                        xhr.setRequestHeader("Access-Control-Allow-Origin", "*");

                       alert("in before send");
                       },

                      // crossDomain: true,
                       dataType: "xml",
                       data: soapMessage,
                       complete: endSaveProduct,
                       contentLength:599,
                       contentType: "text/xml; charset=utf-8"
                       }).done(function () {alert("calling Authenticate");})
                .fail( function() {alert("fail");});
});
var soapMessage='\n';
soapMessage+='\n';
soapMessage+='\n';
soapMessage+='\n';
soapMessage+='1\n';
soapMessage+='1\n';
soapMessage+='\n';
soapMessage+='\n';
soapMessage+='';
$.ajax({
url:“http://myIP/server/xmds.php?wsdl",
类型:“POST”,
发送前:函数(xhr){
//setRequestHeader(“SOAPAction”、“urn:xmds#RestoreDisplayIfAny”);
//setRequestHeader(“主机”http://MYIP/server/");
//setRequestHeader(“SOAPTarget”http://MYIP/server/xmds.php?wsdl");
setRequestHeader(“SOAPAction”http://MYIP/server/");
setRequestHeader(“访问控制允许头”,“*”);
setRequestHeader(“访问控制允许来源”,“*”);
警报(“发送前输入”);
},
//跨域:是的,
数据类型:“xml”,
数据:soapMessage,
完成:endSaveProduct,
内容长度:599,
contentType:“text/xml;charset=utf-8”
}).done(函数(){alert(“调用身份验证”);})
.fail(函数(){alert(“fail”);});
});

此请求是否在同一域内提出?请记住,AJAX不能发出跨域请求。是的,请求是在同一域中发出的。问题是它没有调用那个函数(userdetail)。soap请求结构是否正确??