2011-04-22 65 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