XMLPort in Webservice with Picture export

HollandPoland
Member Posts: 62
Hello all!
I've an XMLPort with a Picture field (BLOB). I want to export the data throught a web service. But unfortunately, the C# code through an exception that the root node is not process. I've seen that the blob field is the problem. I decode it into Base64 like the function in codeunit BizTalkXMLDomMgt, but I have the problem. Is there a way to generate the xml file with XMLPort (using web service)? Thank you in advance. Regards.
I've an XMLPort with a Picture field (BLOB). I want to export the data throught a web service. But unfortunately, the C# code through an exception that the root node is not process. I've seen that the blob field is the problem. I decode it into Base64 like the function in codeunit BizTalkXMLDomMgt, but I have the problem. Is there a way to generate the xml file with XMLPort (using web service)? Thank you in advance. Regards.
0
Comments
-
Hi
WebServices won't like XMLPorts with BLOB fields, most likely because of serialization issues. The way around it, like you rightly say, is to transfer BLOBs using Base64.
Do not include any elements with BLOB data source in your XMLPort, but instead create Text element with TextType=BigText, then fill it in with converted bytes from BLOB.
Below code uses .NET Interop and temporary file to achieve this, but I'm sure there are ways of doing it without going through the filesystem.OBJECT XMLport 50005 BlobTest { OBJECT-PROPERTIES { Date=06/06/13; Time=10:20:09; Version List=; } PROPERTIES { TransactionType=Report; Format/Evaluate=XML Format/Evaluate; DefaultNamespace=urn:microsoft-dynamics-nav/xmlports/x50005; UseDefaultNamespace=Yes; UseRequestForm=Yes; } ELEMENTS { { [{90948DC4-0E6C-4B46-B18B-E6B350E0B1CB}]; ;Blob ;Element ;Text ; MaxOccurs=Once } { [{EC772F8B-CFD7-4D35-A789-F047A2E53522}];1 ;CompanyInfo ;Element ;Table ; VariableName=CompanyInfo; SourceTable=Table79; MinOccurs=Zero; MaxOccurs=Once; Export::OnAfterGetRecord=BEGIN tempFile := Path.GetTempPath() + Path.GetRandomFileName(); CompanyInfo.CALCFIELDS(Picture); IF CompanyInfo.Picture.HASVALUE THEN CompanyInfo.Picture.EXPORT(tempFile); FileMode := 4; FileAccess := 1; FileStream := _File.Open(tempFile, FileMode, FileAccess); MemoryStream := MemoryStream.MemoryStream(); MemoryStream.SetLength(FileStream.Length); FileStream.Read(MemoryStream.GetBuffer(), 0, FileStream.Length); Picture64.ADDTEXT(Convert.ToBase64String(MemoryStream.GetBuffer())); MemoryStream.Close(); MemoryStream.Dispose(); FileStream.Close(); FileStream.Dispose(); _File.Delete(tempFile); END; } { [{150675EA-6BB1-409E-9910-23E7A8F1F949}];2 ;PostCode ;Element ;Field ; DataType=Code; SourceField=CompanyInfo::Post Code } { [{46AA84B5-B634-43DB-9D31-3792EB18AE66}];2 ;Picture64 ;Element ;Text ; TextType=BigText; MaxOccurs=Once } } EVENTS { } REQUESTPAGE { PROPERTIES { } CONTROLS { } } CODE { VAR Convert@1000000007 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Convert"; Path@1000000006 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Path"; _File@1000000005 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File"; FileAccess@1000000004 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileAccess"; FileMode@1000000003 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileMode"; MemoryStream@1000000002 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.MemoryStream"; FileStream@1000000001 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.FileStream"; tempFile@1000000000 : Text[250]; BEGIN END. } }
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