Jaa


Connecting to NAV Web Services from …

I promised to write some posts about how to connect to NAV Web Services from various other programming languages/platforms and I guess it is about time I kept my promise.

I will create a couple of posts on how to connect to NAV Web Services from:

  • PHP
  • Java
  • C# using Web Reference
  • C# using Service Reference
  • Javascript
  • Visual Basic using Web Reference
  • Visual Basic using Service Reference
  • Windows Mobile
  • Microsoft Dynamics NAV 2009SP1
  • and more…

Scenario

For all these I will create some code that:

  • Connects to NAV Web Services System Service and enumerates the companies in the database
  • Constructs a URL to the Customer Page (based on the first company in the list)
  • Get the name of Customer number 10000
  • Get the Customers in GB that have Location Code set to RED or BLUE.

Here is an example of the output of the PHP web site:

image

Note, that the code is not necessarily perfect PHP or Java code and the intention is not to teach people how to code in these languages (I would be a bad teacher) but more to overcome some of the obstacles when trying to work with NAV.

Authentication

The very first obstacle is authentication. As you probably know, NAV 2009 only supported SPNEGO (Negotiate) authentication and both PHP and Java doesn’t currently have any support natively for that.

In NAV 2009 SP1 we added a key in the Service Tier configuration file called WebServicesUseNTLMAuthentication. If you set this key to true the Web Services listener will only use NTLM authentication and as such be easier accessible from other systems.

The config file you need to modify is placed in the directory where the Service Tier executable is and is called CustomSettings.config. The section you are looking for is:

    <!--
Turns on or off NTLM authentication protocol for Web Services
false: Use SPNEGO (recommended)
true: Use NTLM only
-->
<add key="WebServicesUseNTLMAuthentication" value="true"></add>

Note that .net works with both values of this settings.

Enjoy

Freddy Kristiansen PM Architect
Microsoft Dynamics NAV

Comments

  • Anonymous
    January 19, 2010
    Hi Freddy, thanks for sharing. I am trying to use the Dynamics web service from Javascript. I am looking forward to your solution.

  • Anonymous
    January 19, 2010
    You will actually find several solutions using Javascript on my blog here - the virtual earth integration and the gadgets all use Javascript.

  • Anonymous
    January 20, 2010
    Hi Freddy thanks a lot. In general web services are used in the it world, not only in the ms world :) Now I'm searching for a way to use the nav web services in the mac world. Any idea? Using Java or Objectiv-C ?

  • Anonymous
    January 20, 2010
    Unfortunately I do not have a MAC så I cannot make anything happen there - but I would guess the Java sample I wrote should be able to help you.

  • Anonymous
    October 28, 2010
    I don't suppose you have a Ruby example?

  • Anonymous
    October 24, 2011
    Sorry for my english!!!. Do you know Ruby on Rails? I'm trying to connect to Navision from Ruby on Rails. Will you create a post "how to connect to NAV Web Services from ... Ruby on Rails"? Good job Freddy.

  • Anonymous
    March 20, 2012
    Hi Freddy, thanks for the information. Are the follow up posts (c#, javascript, VB.....) available already? Have a nice day.

  • Anonymous
    January 26, 2015
    Thanks Freddy, Great post, Trying to absorb the knowledge given here.

  • Anonymous
    March 01, 2016
    Hi Freddy, Do you have any updates for NAV 2016 Web Service Consumption over Ruby On Rails