Import XML throught XMLport from .NET XmlDocument
drstakz
Member Posts: 30
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:
Some ideas?
Thanks!
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:
My code is:Break On Error Message:
Unable to convert from Microsoft.Dynamics.Nav.Runtime.NavDotNet to Microsoft.Dynamics.Nav.Runtime.NavOutStream.
xmlResponse := xmlResponse.XmlDocument();
MyAddon.GetXml(xmlResponse); // xmlResponse is "out XmlDocument"
// xmlResponse.Save('C:\..\someFile.xml'); // this working
MemoryStream := MemoryStream.MemoryStream();
xmlResponse.Save(MemoryStream);
COPYSTREAM(MemoryStream, InStream); // this not working, error message above
MyXmlPort.SETSOURCE(InStream);
MyXmlPort.IMPORT;
I try convert MemoryStream to OutStream with blob, but without success.
TempBLOB.INIT; TempBLOB.Blob.CREATEOUTSTREAM(OutStream); //MemoryStream.Flush(); //MemoryStream.Position := 0; MemoryStream.CopyTo(OutStream); // I try also .WriteTo(..) -> both case make error COPYSTREAM(OutStream, InStream);
Some ideas?
Thanks!
0
Comments
-
Hi,
I assume this is NAV 2013 R2, as you did not say what NAV version it is.
If this is the case take a look at the XMLport 9170 "Profile Import/Export".IF PageMetadata.LENGTH > 0 THEN BEGIN // OutStream cannot be used directly as it would write the input (metadata blob) as OEM even though it is stored as UTF-8 causing problems for characters not in OEM. // .Net StreamWriter can correctly write UTF-8. "Profile Metadata"."Page Metadata Delta".CREATEOUTSTREAM(MetadataOutStream); streamWriter := streamWriter.StreamWriter(MetadataOutStream,Encoding.UTF8); streamWriter.Write(PageMetadata); END;
If that does not help take a look at this code example for FTP that uses streams
http://www.mibuso.com/forum/viewtopic.php?f=7&t=58425&hilit=FTP
I hope this helps.
Thanks.0 -
drstakz Did you ever find a solution for this?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
