File import to NAV through webservice

Per_Kleberg
Member Posts: 4
Scenario:
External webpage needs to send files (pdf, jpg, docx etc) to NAV.
I've created a table with some fields to hold the files names, extensions etc - And a BLOB-field for the file itself - in NAV.
My problem:
I need a webservice, that can input these different files into my new NAV table. I've tried creating a page with the BLOB field on it, and publishing it as a SOAP webservice, but that didn't work: The webpages developer can "see" all fields BUT the Blob field at his end.. :-(
Any suggestions on how to accomplish this?
External webpage needs to send files (pdf, jpg, docx etc) to NAV.
I've created a table with some fields to hold the files names, extensions etc - And a BLOB-field for the file itself - in NAV.
My problem:
I need a webservice, that can input these different files into my new NAV table. I've tried creating a page with the BLOB field on it, and publishing it as a SOAP webservice, but that didn't work: The webpages developer can "see" all fields BUT the Blob field at his end.. :-(
Any suggestions on how to accomplish this?
0
Best Answer
-
Create a codeunit, add function MyEndpoint (global), and publish the codeunit in the webservices table.
Name DataType Subtype Length
Bytes DotNet System.Array.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Convert DotNet System.Convert.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
MemoryStream DotNet System.IO.MemoryStream.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
MyEndpoint(newdataset : BigText) : Boolean
IF newdataset.LENGTH > 0 THEN BEGIN
Bytes := Convert.FromBase64String(newdataset);
MemoryStream := MemoryStream.MemoryStream(Bytes);
TempBlob.Blob.CREATEOUTSTREAM(OutStr);
MemoryStream.WriteTo(OutStr);
MyTable.init;
MyTable.blob := TempBlob.Blob;
MyTable.insert(true);
EXIT(TRUE);
END;
6
Answers
-
NAV 2017 ;-)0
-
do you need to import the file or you could do with the link?United Kingdom0
-
Create a codeunit, add function MyEndpoint (global), and publish the codeunit in the webservices table.
Name DataType Subtype Length
Bytes DotNet System.Array.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Convert DotNet System.Convert.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
MemoryStream DotNet System.IO.MemoryStream.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
MyEndpoint(newdataset : BigText) : Boolean
IF newdataset.LENGTH > 0 THEN BEGIN
Bytes := Convert.FromBase64String(newdataset);
MemoryStream := MemoryStream.MemoryStream(Bytes);
TempBlob.Blob.CREATEOUTSTREAM(OutStr);
MemoryStream.WriteTo(OutStr);
MyTable.init;
MyTable.blob := TempBlob.Blob;
MyTable.insert(true);
EXIT(TRUE);
END;
6 -
Thanks TallyHo - worked like a charm :-)1
-
I dint completely understood what you want to achieve bur see if this make sense to you
https://rockwithnav.wordpress.com/2017/06/30/file-to-byte-conversion-client-to-server-move/Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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