Sending xml in blobfield to webservice with dotnet NAV2013

greysgreys Member Posts: 29
edited 2014-03-14 in NAV Three Tier
Hi,

I'm upgrading a 2009 database to NAV2013R2 and I am encountering problems with the existing solution of sending a xml to a webservice. Table 'Record' has a field 'XML Message' (blob) which contains a xml-file generated previously by a xmlport. Streams are used to store this content into a xmldomdocument (XMLDoc), which is sent to a webservice later in the process.

Excerpt from code:

Record."XML Message".CREATEINSTREAM(Instr);
Record."XML Message".CREATEOUTSTREAM(OutStr);
Record.CALCFIELDS("XML Message");

IF ISCLEAR(XMLDoc) THEN
CREATE(XMLDoc,FALSE,TRUE);

XMLDoc.load(Instr);

.....

NAV2013 does not like streams apparently, because the above construction halts at the XMLDoc.load(Instr) with the error message 'stream cannot be used with client-side invoked automation'. Changing the third parameter into FALSE does not solve a thing, because NAV2013 won't let me save the object then (error 'You cannot create an Automation object "XMLDoc" on Microsoft Dynamics NAV Server. You must create it on a client computer')......

Since I would like to not be depending on automations anymore, I would love to switch to a dotnet solution. Is there anyone who can help me achieve the same functionality by using dotnet variables? So what I want is loading the xmlcontent of a blob file into a XMLDoc-variable.

Any help would be greatly appreciated!

Best regards,
Greys

Comments

  • vremeni4vremeni4 Member Posts: 323
    Hi,

    Take a look at this blog.

    http://dynamicsuser.net/blogs/waldo/archive/2011/12/20/net-interop-consume-a-third-party-web-service-check-vat-registration-no.aspx


    It may be also worth checking that in that codeunit you always have
    CREATE(XMLDoc,FALSE,TRUE);
    and there is not only
    CREATE(XML);

    I had a similar problem, and compiler would point to a wrong place in the code, but there was a CREATE(XML); before in the code without ,FALSE,TRUE);
    Bottom Line: search for CREATE and make sure that ",FALSE,TRUE);" is always present

    I hope this helps.
  • ara3nara3n Member Posts: 9,256
    look at cu 6224 XML DOM Management. it uses dotnet data types
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ftorneroftornero Member Posts: 524
    You always can do this:

    FileName := FileMgt.ClientTempFileName('xml');
    Record."XML Message".EXPORT(FileName);
    XMLDoc.load(FileName);

    Where:

    FileName is Text
    FileMgt is codeunit 419 (File Management)
    XMLDoc is DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Sign In or Register to comment.