繁体   English   中英

如何验证SOAP请求

[英]How can I validate a SOAP Request

有没有一种快速的方法来验证SOAP消息? 我已经看到JSON对象的验证器。 SOAP是否有类似的东西? 我正在处理的AJAX帖子收到“错误请求:400”错误响应。 我对SOAP不太熟悉,因为通常只传递JSON。 有人可以告诉我我的请求出了什么问题,或者可以提出一种自己调试的好方法吗? Firebug错误消息只是“错误请求:400”,实际上并没有帮助。

<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/'>
    <soap:Body>
        <UpdateAutoChart xmlns='http://somewhere.org/hwconnect/services' soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding'>alertid=Test&companytoken=hw&autochart=false</UpdateAutoChart>
    </soap:Body>
</soap:Envelope>

这是我的POST函数:

function doPost(method, body) {
    var soapRequest = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' ";
    soapRequest = soapRequest + "xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>";
    soapRequest = soapRequest + "<soap:Body>"
    soapRequest = soapRequest + "<" + method + " xmlns='http://somewhere.org/hwconnect/services' soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding'>"; 
    soapRequest = soapRequest + body;
    soapRequest = soapRequest + "</" + method + ">";
    soapRequest = soapRequest + "</soap:Body></soap:Envelope>";
    jQuery.noConflict();
    jQuery.ajax({
        beforeSend: function(xhrObj) {
            xhrObj.setRequestHeader("Method", "POST");
            xhrObj.setRequestHeader("Content-Type", "text/xml; charset=\"utf-8\";");
            xhrObj.setRequestHeader("SOAPAction", "http://somewhere.org/hwconnect/services/" + method);
        },
        async: false,
        type: "POST",
        url: theURL,
        contentType: "text/xml; charset=\"utf-8\";",
        data: soapRequest,
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("XMLHttpRequest Failure: " + XMLHttpRequest.statusText);
        }
    });
}

这可能不是SOAP问题,而是有关如何发布数据的问题:

400错误的解释

我会检查您要发送的最终HTTP标头,以验证它们是否正确(尤其是数据大小)

我不知道json,但soapaction标头应如下所示


SOAPAction: "myaction"

所以这行:


xhrObj.setRequestHeader("SOAPAction", "http://somewhere.org/hwconnect/services/" + method);

应该看起来像这样是正确的:


xhrObj.setRequestHeader("SOAPAction", "\"http://somewhere.org/hwconnect/services/" + method + "\"");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM