XML content question

1
Good day, I try to import the following xml: I receive this as a string into my microflow: <applicanttest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="System.Collections.Generic.List`1[System.Type]"><id>0</id><surname>Test Surname - </surname><firstname>Test Firstname - </firstname><externalreference>123aaaa</externalreference></applicanttest> I did a java println as well, and see this:  in the beginning of the line, weird chars. Is this a soap message wrapper possibly? Will Mendix see this to. As the Core.logger doesn't display this at all. It is on utf-8. I then run a java action to create a file object and populate that and return the file System.FileDocument. -(as previous question, all should be working concerning this). I then import xml this returned file document. It falls over: Caused by: af: FileDatastore: File does not exist at kb.a(SourceFile:51) at jm.a(SourceFile:346) at com.mendix.core.Core.getFileDocumentContent(SourceFile:1382) I added from the java console a test before it returns: Core.getLogger("and").critical(Core.getFileDocumentContent(getContext(), mendixObject)); Which gives: java.io.FileInputStream@7a140f I checked the xml to domain mapping, and the XSD schema. Why doesn't it import this XML?
asked
1 answers
2

This is caused by the different data encodings that are used. When you see the strange characters you are referring to this is almost always an encoding problem.

When you convert a string to a ByteArrayInputStream you should explicitly specify the encoding:

InputStream inputStream = new ByteArrayInputStream(stringXML.getBytes("UTF8"));

Your console test usually doesn't work with Java objects, when you print these objects as string (without some object specific functions) it will almost always print the memory location of the object such as your example.

answered