XML API Integration

navuser1
Member Posts: 1,334
Dear All,
How do I sent a xml file to a webservice in NAV 2016 Platform?
Kindly reply.
Thanks,
Navuser1
How do I sent a xml file to a webservice in NAV 2016 Platform?
Kindly reply.
Thanks,
Navuser1
Now or Never
0
Best Answer
-
Done!
Successfully I'm able to send my created xml file into the Web Service. The following code helps me in this requirement...HttpWebRequestMgt.Initialize('URL'); HttpWebRequestMgt.DisableUI; HttpWebRequestMgt.SetMethod('POST'); HttpWebRequestMgt.AddBody(FilePath); //Xml file path TempBlob.INIT; TempBlob.Blob.CREATEINSTREAM(Instr); IF HttpWebRequestMgt.GetResponse(Instr,HttpStatusCode,ResponseHeaders) THEN BEGIN MESSAGE('HttpStatusCode : '+FORMAT(TempBlob.ReadAsText('',TEXTENCODING::UTF8))); //Save response.... XMLDocumentTest :=XMLDocumentTest.XmlDocument; XMLDocumentTest.Load(Instr); XMLDocumentTest.Save('C:\xml1.xml'); END;
Name DataType Subtype
HttpWebRequestMgt Codeunit Http Web Request Mgt.
TempBlob Record TempBlob
Instr InStream
XMLDocumentTest DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
HttpStatusCode DotNet System.Net.HttpStatusCode.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
ResponseHeaders DotNet System.Collections.Specialized.NameValueCollection.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'Now or Never0
Answers
-
IMHO it depends on what the counterpart of the webservice is. I assume that you have some sort of .NET application consuming the webservice, like an ASP.NET website or a simple C# program.
If this is the case, you can write your xml file into a bigtext and send this via webservice.
Some thing come in handy here:
1. bigtexts can store binary data (including null terminals) up to any size.
2. strings in .NET can have any size and any content0 -
Thanks for the reply.
I have created the XML file & stored it in a physical Path & now I want to send the whole file into a Web Service. Is it possible without considering the bigtext ??Now or Never0 -
Yo can use XMLPorts with webservices. But I have never used these together.0
-
Done!
Successfully I'm able to send my created xml file into the Web Service. The following code helps me in this requirement...HttpWebRequestMgt.Initialize('URL'); HttpWebRequestMgt.DisableUI; HttpWebRequestMgt.SetMethod('POST'); HttpWebRequestMgt.AddBody(FilePath); //Xml file path TempBlob.INIT; TempBlob.Blob.CREATEINSTREAM(Instr); IF HttpWebRequestMgt.GetResponse(Instr,HttpStatusCode,ResponseHeaders) THEN BEGIN MESSAGE('HttpStatusCode : '+FORMAT(TempBlob.ReadAsText('',TEXTENCODING::UTF8))); //Save response.... XMLDocumentTest :=XMLDocumentTest.XmlDocument; XMLDocumentTest.Load(Instr); XMLDocumentTest.Save('C:\xml1.xml'); END;
Name DataType Subtype
HttpWebRequestMgt Codeunit Http Web Request Mgt.
TempBlob Record TempBlob
Instr InStream
XMLDocumentTest DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
HttpStatusCode DotNet System.Net.HttpStatusCode.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
ResponseHeaders DotNet System.Collections.Specialized.NameValueCollection.'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'Now or Never0
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