我想要创建特定函数的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");});
});