是否有一种快速验证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>
这是我的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);
}
});
}
答案 0 :(得分:0)
答案 1 :(得分:0)
我不知道json但是soapaction标题看起来应该是这样的
SOAPAction: "myaction"
所以行:
xhrObj.setRequestHeader("SOAPAction", "http://somewhere.org/hwconnect/services/" + method);
看起来应该是正确的:
xhrObj.setRequestHeader("SOAPAction", "\"http://somewhere.org/hwconnect/services/" + method + "\"");