How to run xmlport get back data to webservie?

yukon
Member Posts: 361
Hi expert,
I create one xmlport at nav. And then i wann to run my xmlport and get data pass to my web. Can we get xml data from nav by using webservice? If it possible, kindly, pls guide tome.
Best Regards,
Yukon:D
I create one xmlport at nav. And then i wann to run my xmlport and get data pass to my web. Can we get xml data from nav by using webservice? If it possible, kindly, pls guide tome.
Best Regards,
Yukon:D
Make Simple & Easy
0
Comments
-
Use the xmlport as parameter of the webservice. If you define it as VAR (called by reference), you can return data through it.0
-
Similar to this: http://blogs.msdn.com/b/nav/archive/2009/11/06/using-dataports-with-web-services.aspx
Alternatively, you could expose a BigText as a VAR, take the incoming request, load that into a Xml Dom object, parse, perhaps do some processing logic and then kick off an xmlport to build xml, clear your bigtext variable and then return the resultant Xml as a string.
It'd look kinda like this:// Processing logic XmlPort.SETTABLEVIEW(Rec); blobTemp.Blob.CREATEOUTSTREAM(OutStream); XmlPort.SETDESTINATION(OutStream); XmlPort.EXPORT; blobTemp.Blob.CREATEINSTREAM(InStream); XmlDomDoc.load(InStream); BigTextVar.ADDTEXT(XmlDomDoc.xml);
Bill0 -
Hi Kine & Bill,
Thanks for your reply. Please me try first. Later i will let you know result.
Best Regards,
YukonMake Simple & Easy0 -
Hi eknraw,
I follow your eg. But when i call function, i got this error. I create one codeunit and i call from nav (for testing).
Any idea for that?
Best Regards, :roll:
YukonMake Simple & Easy0 -
Hi
Solved ready...
Regards,
YukonMake Simple & Easy0 -
Hi eknraw,CREATE(XmlDomDoc);
// Or...
IF ISCLEAR(XmlDomDoc) THEN
CREATE(XmlDomDoc);
You right! I forget above case.
One more thing, i can not set data to BigText. Cos of length is over 1024.
Best Regards,
YukonMake Simple & Easy0 -
One more thing, i can not set data to BigText. Cos of length is over 1024.0
-
Hi deV.ch and kine,
Thanks for your reply.One more thing, i can not set data to BigText. Cos of length is over 1024.bigtext.read(istream);
I'm refer this link http://mibuso.com/forum/viewtopic.php?f=32&t=29557&hilit=MemoryStream&start=15. When i run .net application i got this error "{"Data at the root level is invalid. Line 1, position 1."}". So i checked the return variable at .net. I saw data length is 3. How come? But when i export to text/xml file from nav, i can get all data.
I'm using standard xmlport (item).
Here is my nav codeName DataType Subtype Length objOutStream OutStream objInStream InStream recTempBlob Record TempBlob Item Record Item Var Name DataType Subtype Length Yes BigTextVar BigText Item.SETRANGE("No.",'1000'); Item.FINDSET; recTempBlob.INIT; recTempBlob.Blob.CREATEOUTSTREAM(objOutStream); xmlPort.SETTABLEVIEW(Item); xmlPort.SETDESTINATION(objOutStream); xmlPort.EXPORT; recTempBlob.CALCFIELDS(Blob); recTempBlob.Blob.CREATEINSTREAM(objInStream); BigTextVar.READ(objInStream);
.Net Codelocalhost.Web_Service_Function myInvoicesService = new WindowsApplication1.localhost.Web_Service_Function(); myInvoicesService.UseDefaultCredentials = true; string _BigText = string.Empty; myInvoicesService.FnXML(ref _BigText); //Return length is 3 (data is " þ<") byte[] byteArray = new byte[_BigText.Length]; System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byteArray = encoding.GetBytes(_BigText); System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(byteArray); DataSet ds = new DataSet(); ds.ReadXml(memoryStream);
What wrong at my sample code? Kindly, guide to me.
Best Regards,
YukonMake Simple & Easy0 -
Hi deV.h
Yes! I'm using UTF-16. Now it is ok .... :thumbsup:UTF-16? -> UTF-8
Best Regards,
YukonMake Simple & Easy0
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