我的问题是,我正在做一个重构项目,它是在flash中制作的,必须将其转换为SAUI5,为此,我使用了soap web服务。它包含web服务的多个部分。Ajax调用如下所示:
`var oAppSettings = sap.ui.getCore().getModel("appSettings").getData();
var response;
var oData;
var oXMLModel = new sap.ui.model.xml.XMLModel();
var sReq = "<soapenv:Envelope
xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:web=\"http://webservice.cpb.dqw.sap.com\">\n" +
" <soapenv:Header/>\n" +
" <soapenv:Body>\n" +
" <web:boeLogonWithToken>\n" +
" <!--Optional:-->\n" +
" <web:args0>"+oAppSettings.loginToken+"</web:args0>\n"
+
" </web:boeLogonWithToken>\n" +
" </soapenv:Body>\n" +
"</soapenv:Envelope>";
$.ajax({
url: oAppSettings.serverPath + ".AdminHttpSoap11Endpoint/",
method: "POST",
dataType: "xml",
data: sReq,
//processData:false,
contentType: "text/xml; charset=\"utf-8\"",
success: function (data, textStatus, jqXHR) {
response = data;
console.log(response);
console.log("Is a success!");
},
error: function (xhr, status) {
console.log("Error: : " + status);
},
complete: function (xhr, status) {
console.log(response);
setUpData();
}
});
function setUpData(){
oXMLModel.setData(response);
console.log(oXMLModel.getXML());
}`
我得到的回应是:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:boeLogonWithTokenResponse
xmlns:ns="http://webservice.cpb.dqw.sap.com">
<ns:return xmlns:ax22="http://shared.cpb.dqw.sap.com/xsd"
xmlns:ax21="http://types.cpb.dqw.sap.com/xsd"
xmlns:ax24="http://types.sdk.boe.dqw.sap.com/xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="ax21:CPBAdminResult">
<ax21:contentUpgradeVersion>0</ax21:contentUpgradeVersion>
<ax21:cpInfo xsi:nil="true" />
<ax21:errorData xsi:nil="true" />
<ax21:intValue xsi:nil="true" />
<ax21:projectInfo xsi:nil="true" />
<ax21:reservedData xsi:nil="true" />
<ax21:status>OK</ax21:status>
<ax21:stringArray xsi:nil="true" />
<ax21:stringValue xsi:nil="true" />
</ns:return>
</ns:boeLogonWithTokenResponse>
</soapenv:Body>
</soapenv:Envelope>`
我想知道如何解析由SAPUI5的xml模型返回的xml。
谢谢
发布于 2018-06-09 04:31:35
您的问题似乎想知道如何使用XMLModel (并且您应该等待答案;),因为它比最初看起来更简单,这意味着您不必转换为JSON。
使用中提供的XML创建一个XMLModel实例:
var oModel = new XMLModel();
oModel.loadData("response.xml");
导航到要转到的元素:
var path = "/soapenv:Body/ns:boeLogonWithTokenResponse/ns:return";
oModel.attachRequestCompleted(function(){
var status = oModel.getProperty(path + "/ax21:status");
});
https://stackoverflow.com/questions/50725741
复制相似问题