0

我正在尝试在我的 blackberry phonegap 应用程序中调用基于 spal 的 .net Web 服务并收到错误“服务器无法处理请求。---> 缺少根元素

这是我的代码。

      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. ---&gt; Root element is missing.</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>

有人可以帮帮我吗?我太担心了

4

2 回答 2

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">
于 2013-06-22T12:50:48.197 回答
-1

替换所有行

SoapMessageInXML = +'...';

SoapMessageInXML += '...';
于 2013-06-22T11:56:00.257 回答