XML Serialize for WCF layer

1
Good morning, I tried serializing an object received in the WCF layer to pass back into Mendix as XML document. Seems Mendix doesn't like the XML passed back,as it is a data member in C# being serialized. So the options in my opinion: a) serialize the object to xml, better in the WCF layer, or b) pass it back as string to mendix, and use java action to convert it better. Example: domain.applicant with 4 attributes gets populated and parsed: String tempXML = Serialize((QUIRCWcf.LocalDomain.Domain.Applicant)appl); TempXML will become the wanted XML document in Mendix where the xml can be loaded for processing on a microflow. Example of the WCF layer xml generated after serialization, and how will you pass this back into Mendix as a XML document? What formatted xml is needed for a webservice either from WCF or Java to be read by mendix? Soap format straight? Example xml: <Applicant z:Id="i1" xmlns="http://schemas.datacontract.org/2004/07/QUIRCWcf.LocalDomain.Domain" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/"><Addresses><Address z:Id="i2"><City>CapeTown</City><Country>South Africa</Country><CountryCode>za</CountryCode><DefaultAddress>true</DefaultAddress><Line1>Test Customer (1) Address Line 1 - </Line1><Line2>Test Customer (1) Address Line 2 - </Line2><PostalCode>1234</PostalCode><StateProvince>Western Cape</StateProvince><StateProvinceCode>WC</StateProvinceCode><Suburb>Cape City</Suburb><Type>1</Type><id>0</id></Address><Address z:Id="i3"><City>CapeTown</City><Country>South Africa</Country><CountryCode>za</CountryCode><DefaultAddress>true</DefaultAddress><Line1>Test Customer (2) Address Line 1 - </Line1><Line2>Test Customer (2) Address Line 2 - </Line2><PostalCode>1234</PostalCode><StateProvince>Western Cape</StateProvince><StateProvinceCode>WC</StateProvinceCode><Suburb>Cape City</Suburb><Type>1</Type><id>0</id></Address></Addresses></Applicant>
asked
4 answers
2

You need xml that validates to an XSD. Load up the XSD in mendix (modeler). Then upload the xml to the runtime as a FileDocument. Use an "Import XML" microflow activity to read the filedocument containing the xml file into the Mendix database.

answered
0

Thanks Achiel for your quick response.

I do have a XSD and mapping defined. The problem originally was that the XML serialize in C# doesn't handle Lists. So for now, I seperated the child Lists as it uses an Interface, which is non serializable.

My question is this though: On my microflow, I have an XML document defined, which contains the mapping to the XML-to-Domain on the few fields. All good. Now from the C# point of view, I have to populate this variable on the microflow, which is now an XML Document.

How I return the xml string to a mendix xml document? Or do I read it in as a string containing the xml, and then import that? But I can't as the string can't convert to an xml document.

Example from c#: //this is the published web service in mendix: Test.testWSDLWS newApp = new QUIRCWcf.Test.testWSDLWS();

//xml serialize the object to be returned to mendix //so I sit with an xml string - want to convert this so mendix can read //it String tempXML3 = ToXMLOBJ(test);

//now populate the parameter - which is called xmlDocument on the //microflow for this web service as parameter newApp.XMLDocument = tempXML3;

Sorry for the repeated question, very new to this. Appreciate your help.

answered
0

To ask this better,

From a Java point of view, it is good, because we have the mendix java API. From C#, what will need to pass in from the code to have an microflow XML parameter populated, not being imported, but xml string rather being inserted into the mendix flow.

Hope this makes sense

Thanks to all

answered
0

Why do you not write custom java code to change the string to xml? We had the same problem once that a webservice produced a very lousy xml. So we retrieved it as string handed it over to the custom java action and gave a good xml file back to Mendix.

answered