Calling External Web Services - Blog - SAN Business Solutions

Go to content

Main menu:

Calling External Web Services

Published by in MS Dynamics NAV · 26/1/2017 19:44:00
The following example shows how to communicate with an external web service from MS Dynamics (NAV).
You create a template that you can use to call the web request,  indicating all parameters::
  • Host,
  • Page,
  • Service (optionally with value)

To request data from a host server I use the  .NET Assembly with following method:
WebRequest request = WebRequest.Create(httpGETstring) as HttpWebRequest;
request.Credentials = CredentialCache.DefaultCredentials;
((HttpWebRequest)request).UserAgent = ".NET Framework Example Client";
WebResponse response = request.GetResponse();
Stream dataStream = response.GetResponseStream();
XmlDocument document = new XmlDocument();
XmlNode node = document.ChildNodes[1];
File.WriteAllText(dataXmlFileName, node.InnerText);

Back to content | Back to main menu