I wanted to be able to use the Record Link table in NAV to link to my attachments. Since that part of NAV is not customizable every attachment that I link to NAV needs to be accessible via URL.
So, when I import or scan a file into NAV it can be stored in a BLOB or I can store it in a customized external database. After storing the file I create a URL link to that file and insert that as a new link to any record in NAV. To complete this task I created a NAV Web Service that delivers the file as a base64 string. Here is the part of the code that encodes the BLOB stream to a BigText variable.
TempFileName := TempFile.NAME;
XMLNode := XMLDoc.createNode(‘element’, ‘ImageFile’, ‘SKYRR Signing’);
XMLNode.dataType := ‘bin.base64’;
ADOStream.Type := 1;
XMLNode.nodeTypedValue := ADOStream.Read();
Then I created a aps.net website that can get the document both from this NAV Web Service and also from the customized database all based on the parameters passed with the URL.
Attached is a part of the NAV code and the website required to deliver the attachment.
4 Replies to “Web Service that deliveres BLOB data”
A few questions:
How and through what function in NAV is the blob created ?
The bigtext value “Document” is returned from the webservice?
If it is a large file (blob) won’t that eat away all the memory?
1. The blob is usually created by importing a file. This file can for example be an image, an Excel Document, PDF Document or an XML file. It is also possible to create the blob with XML Port or by writing to an out stream.
2. The bigtext variable will contain a base64 version of the document. This is a similar method that is used when attaching files to an email message. You should be able to use similar rule, that it, files to big for email will also be to big for this web service.
The CREATE of XMLDoc Automation cannot be done in NAV 2015 by Webservices, resulting in an error that no client callback is possible (apperently because NAV wants to pop up a dialog to assure that the CREATE of an unknown Automation is allowed by the user). I read advice in other forums that the dotnet versions of XMLDoc and XMLNode should be used instead. But I don’t find a possibility to set the DataType in an XMLNode to Base64 ´with the dotnet Version. Do you know how to do that? Thank you in advance.
I believe you should find an example of how to use Base64 in this post -> https://dynamics.is/?p=1018