2011-04-22 66 views
0

我已經在xcode框架中的iPad上爲SAP創建了應用程序。使用網頁瀏覽方法我可以在iPad中打開我的應用程序網頁。 html5頁面存儲在我的電腦上。 我的問題是如何通過html5網頁使用SAP SOAP Web服務。我應該先做哪些步驟?我有權訪問SAP ES工作場所。我對此沒有任何想法,因爲這是我的第一個項目。有人能爲我提供適當的視頻教程或特定的鏈接來閱讀。 大部分鏈接都是針對RESTful Web服務的。提前致謝。 而我的網絡服務網址是 「http://erp.esworkplace.sap.com/sap/bc/srt/wsdl/bndg_DF5300E043F279F18F0400145E5ADE89/wsdl11/allinone/ws_policy/document?sap-client=800」,它以wsdl格式打開。 和「MaterialBasicDataByIDQueryResponse_In」這是我的功能名稱在html5網頁中使用jQueryAjax消費SAP soap web服務iPad

回答

1

我強烈推薦REST!這是一個很多的重量越來越輕

我用戶的jQuery在這個例子中 在HTML頁面中

<script id="soap-template" type="application/soap-template"> <?xml version="1.0" encoding="utf-8"?><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><ns0:getSOAP xmlns:ns0="http://localhost:8080/soap"> <search>${id}</search></ns0:getSOAP ></soap:Body></soap:Envelope></script> 

JS:

var soapBody = $("#soap-template").html().replace(
     new RegExp("\\$\\{[^}]+\\}", "i"), 
     search 
     ); 
soapBody = $.trim(soapBody); 
$.ajax({ 
    type: "post", 
    url: "http://localhost:8080/soap", 
    contentType: "text/xml", 
    data: soapBody, 
    dataType: "xml", 
    processData: false, 
    beforeSend: function(xhr){ 
    // Pass the target URL onto the proxy. 
    xhr.setRequestHeader(
    "SOAPTarget", 
    "http://localhost:8080/soap" 
    ); 

    // Pass the action onto the proxy. 
    xhr.setRequestHeader(
    "SOAPAction", 
    "http://localhost:8080/soap/getSOAP" 
    ); 
    }, 
    success: function(response){ 
    // Get a jQuery-ized version of the response. 
    var xml = $(response); 
    //handle your result 

    }, 
    error: function(){ 
     alert("error"); 
    console.log("ERROR", arguments); 
    } 
    }); 
+0

嗨HACHE我嘗試你的代碼,但我無法調用Web服務。我認爲我不熟悉jQuery語法,我沒有得到輸出。你能否提供給我你的電子郵件ID,以便我可以向你發送我的html5編碼,以解決我面臨的這個問題。在這裏,我嘗試粘貼我的html5編碼,但不能很好地與本網站合作。雖然我已經編輯了網絡服務URL和函數名稱的問題。請幫助並回復:) – HardRock 2011-04-30 05:53:00