Options

XMLport & BLOB

lyotlyot Member Posts: 202
I'm having some troubles with the following code:
IF NOT ISCLEAR(lautXmlHttp) THEN
  CLEAR(lautXmlHttp);
CREATE(lautXmlHttp);

IF NOT ISCLEAR(lautXmlDoc) THEN
  CLEAR(lautXmlDoc);
CREATE(lautXmlDoc);

lautXmlDoc.async := FALSE;
lautXmlDoc.validateOnParse := FALSE;
lautXmlDoc.setProperty('ProhibitDTD',FALSE);


recTmpXml.INIT;
recTmpXml."Entry No." := 0;
recTmpXml.INSERT;
recTmpXml.Xml.CREATEOUTSTREAM(outXmlStream);


lxmlCustomer.SETDESTINATION(outXmlStream);
lxmlCustomer.EXPORT;
recTmpXml.MODIFY;
recTmpXml.Xml.EXPORT('c:\blob.xml');


recTmpXml.CALCFIELDS(Xml);
IF recTmpXml.Xml.HASVALUE THEN
  recTmpXml.Xml.CREATEINSTREAM(inXmlStream);

lautXmlDoc.load(inXmlStream);
//TEST
lautXmlDoc.save('c:\Customer.xml');

The file blob.xml is created correct with the right content but... Customer.xml is strangely enough empty ](*,)

Answers

  • Options
    lyotlyot Member Posts: 202
    lautXmlHttp Automation 'Microsoft XML, v6.0'.XMLHTTP60
    lautXmlDoc Automation 'Microsoft XML, v6.0'.DOMDocument
    lxmlCustomer XMLport Export Customer
  • Options
    ara3nara3n Member Posts: 9,255
    try to comment out the following code.

    lautXmlDoc.validateOnParse := FALSE;
    lautXmlDoc.setProperty('ProhibitDTD',FALSE);

    your code looks fine otherwise.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    lyotlyot Member Posts: 202
    Placed them in comment...
    But still empty file :cry:
  • Options
    lyotlyot Member Posts: 202
    When I place
    inXmlStream.READTEXT(bstr,1024);
    MESSAGE(bstr);
    

    Before
    lautXmlDoc.load(inXmlStream);
    

    I get output, so the stream does contain data.
  • Options
    ara3nara3n Member Posts: 9,255
    which executable version of NAV are you using?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    lyotlyot Member Posts: 202
    NAV 4 SP1 SQL
  • Options
    ara3nara3n Member Posts: 9,255
    try it on a newer exe.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    kinekine Member Posts: 12,562
    Try to add CALCFIELDS before you export the BLOB...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    lyotlyot Member Posts: 202
    kine wrote:
    Try to add CALCFIELDS before you export the BLOB...

    I guess al the necessary CALCFIELDS are present nonetheless, I added some more. But still got the same result.
    ara3n wrote:
    try it on a newer exe.

    Just tried it on a 5 SP1 SQL... same result
  • Options
    kinekine Member Posts: 12,562
    lyot wrote:
    kine wrote:
    Try to add CALCFIELDS before you export the BLOB...

    I guess al the necessary CALCFIELDS are present nonetheless, I added some more. But still got the same result.
    ara3n wrote:
    try it on a newer exe.

    Just tried it on a 5 SP1 SQL... same result
    Does it mean that you have tried this?
    lxmlCustomer.SETDESTINATION(outXmlStream);
    lxmlCustomer.EXPORT;
    recTmpXml.MODIFY;
    recTmpXml.CALCFIELDS(Xml);  //----add this line
    recTmpXml.Xml.EXPORT('c:\blob.xml');
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    lyotlyot Member Posts: 202
    kine wrote:
    Does it mean that you have tried this?
    lxmlCustomer.SETDESTINATION(outXmlStream);
    lxmlCustomer.EXPORT;
    recTmpXml.MODIFY;
    recTmpXml.CALCFIELDS(Xml);  //----add this line
    recTmpXml.Xml.EXPORT('c:\blob.xml');
    

    Yep, and even without the calcfields there isn't a real problem because the blob.xml alwasys contains the right data.

    The problem starts when I load the contents of the blob in a InStream and when I load that Instream in a XML doc.
    recTmpXml.CALCFIELDS(Xml);
    IF recTmpXml.Xml.HASVALUE THEN
      recTmpXml.Xml.CREATEINSTREAM(inXmlStream);
    
    lautXmlDoc.load(inXmlStream);
    //TEST
    lautXmlDoc.save('c:\Customer.xml');
    

    Just to be sure if my xmldoc contains the right data, I save it to a file (debugging purpose).
    The file customer.xml is created but it contains no data... at that point I'm quite sure that the rest of my code who will send the xml doc to a webservice
    will not work either.
  • Options
    kinekine Member Posts: 12,562
    Ok, I missed this part...

    When I need to export XMLPort into xmldom,I am using this structure:
    lreTempBlob.Blob.CREATEOUTSTREAM(losStream);
    XMLPORT.EXPORT(XMLPORT::"Export Customers",losStream);
    
    lreTempBlob.Blob.CREATEINSTREAM(lisStream);
    lauXmlDom.load(lisStream);
    

    I am not doing insert, modify, calcfields etc. and it is working for me... :-k (lreTempBlob is temporary record over table 99008535)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    lyotlyot Member Posts: 202
    Still no luck :-k
    This getting very strange...
  • Options
    lyotlyot Member Posts: 202
    For debugging purposes I have written the following:
    CreateInStream;
    
    
    WHILE NOT (inXmlStream.EOS()) DO
    BEGIN
      int:= inXmlStream.READTEXT(test,100);
      MESSAGE(test + ' Size: ' + FORMAT(int));
    END;
    
    
    lautXmlDoc.load(inXmlStream);
    

    This shows me the content of inStream and it contains my xml file... So no problem there.
  • Options
    lyotlyot Member Posts: 202
    When I activate the code that actualy sends the xml file to my webservice, I get the following error:

    Microsoft Business Solutions-Navision
    This message is for C/AL programmers:

    The call to member send failed. msxml6.dll returned the following message:
    Een naam bevat een ongeldig teken. (The name contains an invalid character)
    OK

    Unless a blank file is considered as an invalid character...?
    Maybe there's an invalid character in the xml that prevents lautXmlDoc.save('c:\Customer.xml');

    Just guessing...
  • Options
    lyotlyot Member Posts: 202
    Problem fixed...
    There we're spaces in the element names of the exported xml... #-o #-o #-o
Sign In or Register to comment.