Hi,
I am trying to comsume an oData service (published from a Mendix app) and get an xml result so I can use an import mapping to process the result.
When I write the Rest call response to a string, I get this xml string:
<?xml version="1.0" encoding="UTF-8"?><feed xml:base="http://ga:8080/odata/Published_OData_service/" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns="http://www.w3.org/2005/Atom"> <id>http://ga:8080/odata/Published_OData_service/Garantie</id> <title>Garantie</title> <updated>2017-06-14T13:06:32.053Z</updated> <link href="Garantie" rel="self" title="Garantie"/> <entry> <id>http://ga:8080/odata/Published_OData_service/Garantie(16044073672509093)</id> <category term="DefaultNamespace.Garantie" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/> <title/> <updated>1970-01-01T00:00:00.000Z</updated> <content type="application/xml"> <m:properties> <d:ID m:type="Edm.Int64">16044073672509093</d:ID> <d:Garantienummer m:type="Edm.Int64">4</d:Garantienummer> <d:Status m:type="Edm.String">Actief</d:Status> <d:TotaalLeningbedrag m:type="Edm.Decimal">2800000</d:TotaalLeningbedrag> <d:GegarandeerdBedrag m:type="Edm.Decimal">0</d:GegarandeerdBedrag> <d:Begindatum m:type="Edm.DateTimeOffset">2016-11-18T00:00:00.000Z</d:Begindatum> <d:Melddatum m:type="Edm.DateTimeOffset">2016-11-21T09:51:36.234Z</d:Melddatum> <d:Einddatum m:type="Edm.DateTimeOffset" m:null="true"/> <d:_HeeftWaarschuwing m:type="Edm.Boolean">false</d:_HeeftWaarschuwing> <d:TotaalBedragAflossing m:type="Edm.Decimal">0</d:TotaalBedragAflossing> <d:AnnuitaireDaling m:type="Edm.Decimal">0</d:AnnuitaireDaling> <d:OpgebouwdeWaarde m:type="Edm.Decimal">0</d:OpgebouwdeWaarde> <d:GeborgdBedrag m:type="Edm.Decimal">0</d:GeborgdBedrag> </m:properties> </content> </entry></feed>
Now in order to make the mapping, I was trying to create an XSD from this XML using free online "XML to XSD converter", but I have tried five different converters and they all produce different XSDs which all give errors when trying to import them into the modeler. The XSD I have had the best succes with is:
<?xml version="1.0" encoding="utf-8"?><xs:schema id="NewDataSet" targetNamespace="http://www.w3.org/2005/Atom" xmlns:mstns="http://www.w3.org/2005/Atom" xmlns="http://www.w3.org/2005/Atom" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:app1="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:app2="http://schemas.microsoft.com/ado/2007/08/dataservices"> <xs:import namespace="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" schemaLocation="636331195910115922_odata.xml_app1.xsd" /> <xs:import namespace="http://schemas.microsoft.com/ado/2007/08/dataservices" schemaLocation="636331195910115922_odata.xml_app2.xsd" /> <xs:element name="feed"> <xs:complexType> <xs:sequence> <xs:element name="id" type="xs:string" minOccurs="0" /> <xs:element name="title" type="xs:string" minOccurs="0" /> <xs:element name="updated" type="xs:string" minOccurs="0" /> <xs:element name="link" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="href" form="unqualified" type="xs:string" /> <xs:attribute name="rel" form="unqualified" type="xs:string" /> <xs:attribute name="title" form="unqualified" type="xs:string" /> </xs:complexType> </xs:element> <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="id" type="xs:string" minOccurs="0" /> <xs:element name="title" type="xs:string" minOccurs="0" /> <xs:element name="updated" type="xs:string" minOccurs="0" /> <xs:element name="category" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="term" form="unqualified" type="xs:string" /> <xs:attribute name="scheme" form="unqualified" type="xs:string" /> </xs:complexType> </xs:element> <xs:element name="content" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element ref="app1:properties" /> </xs:sequence> <xs:attribute name="type" form="unqualified" type="xs:string" /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="feed" /> </xs:choice> </xs:complexType> </xs:element></xs:schema>
Which I changed a bit because the "properties" element wasn't declared (and its simple attributes are nowhere to be found). So I created this XSD:
<?xml version="1.0" encoding="utf-8"?><xs:schema id="NewDataSet" targetNamespace="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns="http://www.w3.org/2005/Atom"> <xs:element name="feed"> <xs:complexType> <xs:sequence> <xs:element name="id" type="xs:string" minOccurs="0" /> <xs:element name="title" type="xs:string" minOccurs="0" /> <xs:element name="updated" type="xs:string" minOccurs="0" /> <xs:element name="link" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="href" form="unqualified" type="xs:string" /> <xs:attribute name="rel" form="unqualified" type="xs:string" /> <xs:attribute name="title" form="unqualified" type="xs:string" /> </xs:complexType> </xs:element> <xs:element name="entry" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="id" type="xs:string" minOccurs="0" /> <xs:element name="title" type="xs:string" minOccurs="0" /> <xs:element name="updated" type="xs:string" minOccurs="0" /> <xs:element name="category" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="term" form="unqualified" type="xs:string" /> <xs:attribute name="scheme" form="unqualified" type="xs:string" /> </xs:complexType> </xs:element> <xs:element name="content" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="properties"> <xs:complexType> <xs:sequence> <xs:element name="ID" type="xs:int"/> <xs:element name="Garantienummer" type="xs:int"/> <xs:element name="Status" type="xs:string"/> <xs:element name="TotaalLeningbedrag" type="xs:int"/> <xs:element name="GegarandeerdBedrag" type="xs:int"/> <xs:element name="Begindatum" type="xs:string"/> <xs:element name="Melddatum" type="xs:string"/> <xs:element name="Einddatum" type="xs:string"/> <xs:element name="_HeeftWaarschuwing" type="xs:string"/> <xs:element name="TotaalBedragAflossing" type="xs:int"/> <xs:element name="AnnuitaireDaling" type="xs:int"/> <xs:element name="OpgebouwdeWaarde" type="xs:int"/> <xs:element name="GeborgdBedrag" type="xs:int"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element></xs:schema>
Which imports perfectly and even leads to a very convincing import mapping:
Only problem: The properties element is always empty, even though in the xml, you can clearly see it has content.
Can someone help me fabricate a good XSD with which I can consume my oData service.