本文介绍了将SOAP服务绑定到SAPUI5 simpleform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在SAPUI5中使用textviews创建了一个简单的表单。
我必须将SOAP服务中的数据绑定到我的表单。
如何做到这一点?
这是表单,service.view.xml
I have created a simple form in SAPUI5 with textviews.I have to bind the data from SOAP service to my form.How to do that?Here is the form , service.view.xml
<mvc:View controllerName="themes.controller.service" xmlns:f="sap.ui.layout.form" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:mvc="sap.ui.core.mvc" xmlns:semantic="sap.m.semantic" xmlns:table="sap.m.table" xmlns="sap.m">
<Bar id="bar4">
<contentLeft>
<Button icon="sap-icon://nav-back" press="onNavBack"/>
<Button icon="sap-icon://home" press="onNavBack"/>
</contentLeft>
<contentRight>
<Button icon="sap-icon://account" press="handleAccount"/>
</contentRight>
</Bar>
<Page id="pag1">
<content>
<f:SimpleForm id="form3" columnsL="1" columnsM="1" editable="false" emptySpanL="4"
emptySpanM="4" labelSpanL="3" labelSpanM="3" layout="ResponsiveGridLayout" maxContainerCols="2" minWidth="1024" >
<f:content>
<Label text="Country"/>
<Text text="{country}"/>
<Label text="Phone Number"/>
<Text text="{phone}"/>
<Label text="Carrier"/>
<Text text="{carrier}"/>
<Label text="Incoterms"/>
<Text text="{incoterms}"/>
</f:content>
</f:SimpleForm>
</content>
</Page>
<Bar id="bar5">
<contentLeft>
<Button icon="sap-icon://email" press="handleContact"/>
</contentLeft>
</Bar>
我如何处理模型创建和从SOAP服务中获取值?
由于我只熟悉OData服务,请帮我绑定SOAP服务中的值
How do I work on the model creation and taking values from the SOAP service?As I am only familiar with OData service please help me in binding the values from SOAP service
推荐答案
它可以是做得相当简单(与Marc评论的相反,你只需要一个 $。ajax
调用)和一个 sap.ui.model.xml .XMLModel
:
It can be done fairly easy (and contrary to what Marc commented, you'll need just one $.ajax
call) and an sap.ui.model.xml.XMLModel
:
// first create your SOAP request envelope
var soapRequest = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope/\" soap:encodingStyle=\"http://www.w3.org/2003/05/soap-encoding\">" +
" <soap:Body>" +
" <m:GetPrice xmlns:m=\"http://www.w3schools.com/prices\">" +
" <m:Item>Apples</m:Item>" +
" </m:GetPrice>" +
" </soap:Body>" +
"</soap:Envelope>";
// instantiate an XMLModel
var oModel = new sap.ui.model.xml.XMLModel();
$.ajax(sURL, { // sURL is the url you are sending the SOAP request to
method: "POST",
data: soapRequest,
dataType: "xml",
contentType: "text/xml; charset=\"utf-8\""
}).done(function(data, textStatus, jqXHR) {
// in the 'done' Promise, store the SOAP response into your XMLModel
oModel.setData(data);
}).fail(function(XMLHttpRequest, textStatus) {
jQuery.sap.log.fatal("The following problem occurred: " + textStatus, XMLHttpRequest.responseText + "," + XMLHttpRequest.status + "," + XMLHttpRequest.statusText);
});
参见了解更多信息
这篇关于将SOAP服务绑定到SAPUI5 simpleform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!