2012-11-30 83 views
0

我需要將數據發佈到我的後端系統(SAP)。我嘗試使用下面的代碼:jQuery.Ajax發佈到webservice

硬編碼的URL例如:

var dataString = "" 
    //Add TO SAP. 
    var aData = 
      jQuery.ajax({ 
       type: "POST", 
       //contentType: "application/xml", 
       url: "http://delyo001.you.local:8000/sap/bc/youconsulting/ws/rest/anonymous/z_names_post?firstname=testz&lastname=zefzef", // for different servers cross-domain restrictions need to be handled 
       data: dataString, 
       //dataType: "json" 

       success: function(xml) { // callback called when data is received 
        //oModel.setData(data);    // fill the received data into the JSONModel 
        alert("success to post"); 
       }, 

       error: function(xml) { // callback called when data is received 
        //oModel.setData(data);    // fill the received data into the JSONModel 
        alert("fail to post"); 
        alert(xml); 
       } 
      }); 

的Web服務通過SOAPUI工作。但不是通過這種方式。

任何人都可以請指導這個代碼有什麼問題。

親切的問候, 文森特

+0

您是否收到任何錯誤? –

+0

是的警報無法發佈後觸發,問題是它在soapui中正常工作。我無法獲得任何特定的錯誤消息。 – Vinozio

回答

0

嘗試設置一個標題爲:

header : { "Content-Type" : "application/x-www-form-urlencoded" }

+0

感謝您的答覆,但它沒有工作,螢火透露更多信息: http://i.imgur.com/DvCOF.png – Vinozio

+0

新的錯誤與此代碼: http://pastie.org/5457519 NetworkError:405方法不允許 - http://delyo001.you.local:8000/sap/bc/youconsulting/ws/rest/anonymous/z_names_post – Vinozio