如何验证SOAP请求

时间:2022-05-25 20:12:48

Is there a a quick way to validate SOAP messages? I have seen validator for JSON objects. Is there something like this for SOAP? I am receiving a 'Bad Request: 400' error response with a AJAX post I am working on. I am not too familiar with SOAP as I typically just pass JSON. Can someone tell me what is wrong with my request or perhaps suggest a good way to debug it myself? Firebug error message is just 'Bad Request: 400' which doesn't really help.

有没有一种快速验证SOAP消息的方法?我见过JSON对象的验证器。 SOAP有这样的东西吗?我收到一个'Bad Request:400'错误响应,我正在处理一个AJAX帖子。我不太熟悉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>

This is my POST function:

这是我的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);
        }
    });
}

2 个解决方案

#1


0  

This is probably not a SOAP issue but an issue with how you're posting the data:

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

400 error explained

400错误解释

I'd examine the final HTTP headers you're sending to verify they are correct (especially the data size)

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

#2


0  

I don´t know json but soapaction header should look like this

我不知道json但是soapaction标题看起来应该是这样的


SOAPAction: "myaction"

so the line:

所以这一行:


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

should probably look like this to be correct:

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


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

#1


0  

This is probably not a SOAP issue but an issue with how you're posting the data:

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

400 error explained

400错误解释

I'd examine the final HTTP headers you're sending to verify they are correct (especially the data size)

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

#2


0  

I don´t know json but soapaction header should look like this

我不知道json但是soapaction标题看起来应该是这样的


SOAPAction: "myaction"

so the line:

所以这一行:


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

should probably look like this to be correct:

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


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