2009-12-11 174 views
0

有沒有一種快速驗證SOAP消息的方法?我看過JSON對象的驗證器。有沒有像這樣的SOAP?我正在接收我正在處理的AJAX文章中的'錯誤的請求:400'錯誤響應。我不太熟悉SOAP,因爲我通常只是通過JSON。有人能告訴我我的請求有什麼問題,或者建議自己調試嗎? Firebug錯誤消息只是'錯誤的請求:400',這並沒有真正的幫助。如何驗證SOAP請求

<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

此外,查看線路併發布實際發送的完整XML。 – 2009-12-11 23:27:23

回答

0

這可能不是一個SOAP問題,但如果一個問題,你是如何發佈的數據:

400 error explained

我d檢查您發送的最終HTTP標頭,以確認它們是否正確(尤其是數據大小)

+0

去看看標題..謝謝 – Nick 2009-12-11 15:37:23

0

我不知道,但JSON SOAPAction頭看起來應該是這樣


SOAPAction: "myaction" 

太行:


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

或許應該像這樣是正確的:


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