我正在尝试在我的blackberry phonegap应用中调用基于spal的.net网络服务并收到错误“服务器无法处理请求.-->根元素丢失”
这是我的代码。
var SoapMessageInXML = '<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/">';
SoapMessageInXML +='<soap:Body>';
SoapMessageInXML +='<Login xmlns="http://tempuri.org/">';
SoapMessageInXML +='<aUserName>3007800000</aUserName>';
SoapMessageInXML +='<aPassword>27hitec0</aPassword>';
SoapMessageInXML +='<DeviceID>2</DeviceID>';
SoapMessageInXML +='</Login>';
SoapMessageInXML +='</soap:Body>';
SoapMessageInXML +='</soap:Envelope>';
$.ajax({
type: 'POST',
data: SoapMessageInXML,
contentType: "text/xml",
dataType: "text",
cache: false,
url: 'https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http://50.57.84.5/MobiTicker_mktService/MobileTicker.asmx?op=Login',
success: function (data) {
console.log(data);
},
error: function (xhr) {
console.log(xhr);
}
});
回复
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Receiver</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">Server was unable to process request. ---> Root element is missing.</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>
是的,有人可以帮帮我吗?
我太担心了
答案 0 :(得分:0)
替换所有行
SoapMessageInXML = +'...';
与
SoapMessageInXML += '...';
答案 1 :(得分:0)
当您在XML中封装SOAP消息时,标题元素应该与此类似吗?
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">