Hi!
Pls, I have codeunit with external add-on (dotnet variable) which returning some XmlDocument (next dotnet var.). I want import this XML throught XMLport to database. But I don’t want use file system for save xml to disk and read it back to NAV (at 21th century).
My idea is load XML to XmlDocument and write it to MemoryStream and this stream hand over to xmlPort for import.
But i have problem with convert .net stream to “nav” stream:
Break On Error Message: Unable to convert from Microsoft.Dynamics.Nav.Runtime.NavDotNet to Microsoft.Dynamics.Nav.Runtime.NavOutStream.
My code is:
xmlResponse := xmlResponse.XmlDocument(); MyAddon.GetXml(xmlResponse); // xmlResponse is "out XmlDocument" // xmlResponse.Save('C:\..\someFile.xml'); // this working
Hi, this problem I can no longer remember. But I have in my research database similar solution. I consider that this works, only problem with encoding, this not properly resolved (Czech chars).
xmlResponse1 := xmlResponse1.XmlDocument();
IF Addon1.GetResponse(xmlResponse1) THEN BEGIN
CLEAR(BigText1);
BigText1.ADDTEXT(’<?xml version="1.0" encoding="windows-1250" ?>’); // DotNet addon return xmlDocument without this
BigText1.ADDTEXT(xmlResponse1.InnerXml);
Document1.Blob.CREATEOUTSTREAM(OutStream1); // Just as initialization, Document1 is Table 99008535
Document1.Blob.CREATEINSTREAM(InStream1); // Just as initialization, Document1 is Table 99008535
It might come to late, but for the people that will come and visit this forum searching for a solution to this problem that does not break the encoding try the following :