XMLPorts and XML Document Automation

bochinchabochincha Member Posts: 4
edited 2012-02-16 in NAV Three Tier
My question is so simple.
I need to use a XML Document (declared as a Automation variable) with a XML Port created on the Classic Client.
I´ve been search in the forum and found some responses on how to load a XML Document but there is no responses in the other way.
I try this code (and some more) but doesn´t work:

TempBlob.Blob.CREATEINSTREAM(StreamIn);
XMLDoc.load(StreamIn);

// Llamada al XML Port
CLEAR(xmlImportacion);
xmlImportacion.SETSOURCE(StreamIn);
xmlImportacion.IMPORT;

Has anybody the same problem or it's easier than this.
I´m thinking that the only way its saving the XML Document to disk and then read it ...
So frustrated ](*,)

Comments

  • VjekoVjeko Member Posts: 55
    What exactly are you trying to do? If you have your XML data in your MSXML DOMDocument automation variable, stream it out into a blob:
    CLEAR(TempBlob.Blob);
    TempBlob.Blob.CREATEOUTSTREAM(Outstr);
    XmlDoc.save(Outstr);

    Now your blob keeps the XML data. Then stream into an instream:
    TempBlob.CALCFIELDS(Blob);
    TempBlob.CREATEINSTREAM(Instr);

    Then import it using the XMLport:
    CLEAR(XmlImport);
    XmlImport.SETSOURCE(Instr);
    XmlImport.IMPORT;

    And it must work.
    (Co-)author of "Implementing Microsoft Dynamics NAV 2009"
    http://vjeko.com/
  • bochinchabochincha Member Posts: 4
    Thanks a lot. That´s exactly what I was looking for.
    I tried with the same instructions but need something more.
    Only one thing, you must modify your code because the highlighted line need a little modification.

    CLEAR(TempBLOB.Blob);
    TempBLOB.Blob.CREATEOUTSTREAM(Outstr);
    XmlDoc.save(Outstr);
    TempBLOB.CALCFIELDS(Blob);
    TempBLOB.Blob.CREATEINSTREAM(Instr);
    XMLPORT.IMPORT(NoXMLPort,Instr);

    Thanks again
  • VjekoVjeko Member Posts: 55
    Yes, you are right :) Things happen when you are writing the code from head into here, not testing it in C/AL. But you got the point ;)
    (Co-)author of "Implementing Microsoft Dynamics NAV 2009"
    http://vjeko.com/
Sign In or Register to comment.