XML string to Mendix object

3
Hi there, I am doing a call to a web service that returns a single string value. This string value is in XML format. My question is, what would be the best way of converting this XML string into an object? Example : Return Value of the Web service is '<TestClass><inValue1>15</inValue1><inValue2>21</inValue2></TestClass>'. I would like to convert this string to a "TestClass" Entity.
asked
2 answers
3

The web service you're calling returns just one string value, which happens to contain XML? So the actual response looks like this? :

&lt;TestClass&gt;&lt;inValue1&gt;15&lt;/inValue1&gt;&lt;inValue2&gt;21&lt;/inValue2&gt;&lt;/TestClass&gt;

I've seen web services like this before, and here are a few options to handle them with Mendix:

  • Change the web service (if possible) to return "real" XML: while I've seen the above being used in some systems, it really isn't the way a "good" SOAP web service should function.
  • Do you have any tooling available that you can put between Mendix and the web service you're trying to call that can transform the result into a normal XML message? In cases like this we're using a custom ESB-like messaging framework for transforming these weird formats in normal, "Mendix friendly", XML.
  • You can add a bit of Java code to your Mendix project that stores that string value as the content of a System.FileDocument object, which you can then use in a Mendix XML-to-Domain mapping as you'd normally do.
answered
1

You want to convert the inValue to a Test Class entity. Why not mapping to a TestClass object with a InValue attribute?

answered