【发布时间】:2009-12-11 15:23:37
【问题描述】:
是否有一种快速验证 SOAP 消息的方法?我见过 JSON 对象的验证器。 SOAP 有这样的东西吗?我收到一个“错误请求:400”错误响应,其中包含我正在处理的 AJAX 帖子。我对 SOAP 不太熟悉,因为我通常只传递 JSON。有人可以告诉我我的请求有什么问题,或者可能建议一种自己调试的好方法吗? Firebug 错误消息只是 'Bad Request: 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);
}
});
}
【问题讨论】:
-
另外,查看线路并发布实际发送的完整 XML。
标签: c# asp.net javascript ajax soap