我正在开发SAPUI5并制作oData.request我遇到了一个无法解决的问题: SAP期望以下XML:
<?xml version="1.0" encoding="UTF-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<atom:content type="application/xml">
<m:properties>
<d:Documenttype>DPD</d:Documenttype>
<d:Statusextern>RE</d:Statusextern>
<d:Documentcategorycode>1</d:Documentcategorycode>
<d:LanguageIso_Doc>EN</d:LanguageIso_Doc>
<d:Description>Prueba texto corto</d:Description>
<d:ComputerAidedDesignDrawing>TRUE</d:ComputerAidedDesignDrawing>
</m:properties>
</atom:content>
<atom:link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ti_classallocations" type="application/atom+xml;type=feed">
<m:inline>
<atom:feed>
<atom:entry>
<atom:content type="application/xml">
<m:properties>
<d:Classtype>017</d:Classtype>
<d:Classname>CLDPD</d:Classname>
</m:properties>
</atom:content>
</atom:entry>
</atom:feed>
</m:inline>
</atom:link>
</atom:entry>
我执行此oData.request,但是因为第二个链接需要是xml中的类型Feed宽度Feed标记而得到错误,我无法得到它:
var sServiceUrl = "/sap/opu/odata/TENR/GW_DMS_01_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
sap.ui.getCore().setModel(oModel);
OData.request ({
requestUri: "http://sapgtd75.tenaris.techint.net:8000/sap/opu/odata/TENR/GW_DMS_01_SRV/DmsDocumentHeaderSet",
method: "POST",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type" : "application/atom+xml",
},
data: {
Documenttype : "DPD",
Statusextern : "RE",
Documentcategorycode : "1",
LanguageIso_Doc : "EN",
Description : "Prueba desde UI5",
ComputerAidedDesignDrawing: "TRUE",
"ti_classallocations": {
__metadata: {
uri : "ti_classallocations",
},
Classtype: "017",
Classname: "CLDPD",
},
},
},
function (data, response) {
},
function(err) {
alert(err.response.body);
}
);
生成的XML是:
<?xml version="1.0" encoding="UTF-8"?>
<a:entry xmlns:a="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<a:author>
<a:name />
</a:author>
<a:content type="application/xml">
<m:properties>
<d:Documenttype>DPD</d:Documenttype>
<d:Statusextern>RE</d:Statusextern>
<d:Documentcategorycode>1</d:Documentcategorycode>
<d:LanguageIso_Doc>EN</d:LanguageIso_Doc>
<d:Description>Prueba desde UI5</d:Description>
<d:ComputerAidedDesignDrawing>TRUE</d:ComputerAidedDesignDrawing>
</m:properties>
</a:content>
<a:link href="ti_classallocations" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ti_classallocations" type="application/atom+xml;type=entry">
<m:inline>
<a:entry>
<a:author>
<a:name />
</a:author>
<a:id>ti_classallocations</a:id>
<a:content type="application/xml">
<m:properties>
<d:Classtype>017</d:Classtype>
<d:Classname>CLDPD</d:Classname>
</m:properties>
</a:content>
</a:entry>
</m:inline>
</a:link>
</a:entry>
有人可以帮我解决这个问题吗? 我很难完成开发。