Web services Phonegap XMLHttpRequest POST SOAP数据包

Web services Phonegap XMLHttpRequest POST SOAP数据包,web-services,cordova,xmlhttprequest,Web Services,Cordova,Xmlhttprequest,我有一个PhoneGap iOS应用程序,我想将SOAP数据包发布到web服务并获得响应。如果我没有设置SOAPAction头,POST可以工作,但服务器返回错误,因为它需要SOAPAction头 如果我设置了SOAPAction头,onreadystatechange永远不会触发 var xhr = new XMLHttpRequest(); xhr.open ("POST", url); xhr.setRequestHeader("SOAPAction", "htt

我有一个PhoneGap iOS应用程序,我想将SOAP数据包发布到web服务并获得响应。如果我没有设置SOAPAction头,POST可以工作,但服务器返回错误,因为它需要SOAPAction头

如果我设置了SOAPAction头,
onreadystatechange
永远不会触发

    var xhr = new XMLHttpRequest();

    xhr.open ("POST", url);
    xhr.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/sharepoint/soap/GetListItems");
    xhr.setRequestHeader("Method", "POST "+url+" HTTP/1.1");
    xhr.setRequestHeader("Content-Type","text/xml; charset=utf-8");
    xhr.send ('SOAP here');
    xhr.onreadystatechange = function (event) {
    //etc etc

为什么设置SOAPAction头会完全杀死xhr,阻止onreadystatechange触发?

在调用任何函数之前,您可以注册
onreadystatechange
回调;在创建
xhr
之后添加行。好的,我在xhr创建之后将
放在readystatechange
上,但是
xhr.readyState
只能得到1