• Michael Intravartolo

Programming with NAV Web Services - The Basics


These are my notes and references that I use when consulting and training on how to use Microsoft Dynamics NAV Web Services to accomplish various tasks.

The Basics

There are a handful of steps that are the same regardless of what task you are attempting.

  • Identify the Page

  • Publish the Web Service

  • Test the URL in a Web Browser

  • Add a Service Reference to Your Project

  • Write Some Code

Identify the Page

Interactions with NAV start with your requirements. For this sample, we will assume that you have been asked to display a list of Items for sale.

This also means that all of Navision's validation routines are run when you attempt to modify data.

So, the first step then, is to identify the User Interface or "Page" that an end user would use to accomplish the task.

Looking around in NAV, you find the Items for sale in a convenient, "Item List" interface.


This leads to the biggest "gotcha" with NAV Web Services. Since you want to show a list of Items, the intuitive step would be to use the "Item List" interface.

This is wrong. What you want to do is use the single item interface.

For our purposes, that means we want to use the detail view for one item (the "Item Card") that is accessed by double-clicking an item in the above list.

Once you are on the detail page, select About This Page from the Help Menu


This opens up a Help Screen that tells you the Page Name and Number needed for the next step.

It also tells you the Source Table that the data comes from in case you want to poke around in SQL and make sure you are getting the data you think you are.

Now we know we want Page 30 -- Item Card.


Publish the Web Service

This is the easy part.

Naviage to the Web Services interface (Departments->Administration->IT Administration->General->Web Services) and select the New button.

Object Type is Page (We'll talk about the other types later).

Object ID is 30 -- This is the Page Number that we identified ini the earlier step.

Service Name -- This becomes part of the URL that you use to access the Web Service, so pick something simple and memorable. I picked "Item" for this.

Check the Published checkbox.

That's it. Your Web Service is now available.


Test the URL in a Web Browser

This is the pattern for your Web Service URL:

http://<Server>:<WebServicePort>/<ServerInstance>/WS/<CompanyName>/Page/<ServiceName>

Microsoft fully explains each piece of the URL here:

http://msdn.microsoft.com/en-us/library/dd355398.aspx

Most of the pieces of the URL can be discovered using the Select Server dialog in the NAV Role-Tailored Client.


For this sample, Server = 192.168.10.12 – you can use a Windows Name on your local network (e.g. NAVSERVER) or you can use an internet address such as (navservices.cronuscorp.net).

Although, if you publish over the internet, you will want to use SSL.

This is a bit beyond the scope of this blog post, but you need to send a Windows Login to NAV Web Services, so be sure you or your network administrator fully understand the security implications of what you are doing if you expose services over the public internet.

For SOAP Services Port is 7047 by default.

The Server Instance in this case is commercer2

So, the first part of the URL would be:

http://192.168.10.12:7047/commercer2

Finishing up, the next part is the constant string WS.

The Company Name is the company you wish to connect to. We will use CRONUS Supply, Inc. from the Select Server dialog.

The rest of the information comes from the Web Services page in NAV where you published the service.

The next piece is the Object Type from the Web Services page. Ours will be Page because that is the only type we know how to use right now.

Finally, the Service Name is the name we gave when we published the service. Item for our example.

This then is our final URL:


This is the simplest way to be sure you have the URL correct and the infrastructure is available before you sit down to write code. If the Web Service does not send XML to the browser, then you will need to work with your Network Administrator to be sure the services are published and you are using the correct URL.

Add a Service Reference to Your Project

After all that, we are ready to open up Visual Studio and get to work.

I set up a simple ASP.NET Empty Web Site using the File -> New Web Site dialog in Visual Studio.

Once you have your project started, right-click on your project in Solution Explorer and select Add Service


In the Add Service Reference dialog, paste the URL for the service from the earlier step and select the Go button.

The Namespace field is how you will refer to the generated code in your project, so I like to change the default to something a bit more descriptive. I used ItemService for this sample.


Write Some Code

At this point, you are ready to write some code to perform the task at hand.

I will break down some of the more common tasks in seperate posts, because the above preliminary work is the same regardless of the task.

What's Next?

We get to see some code. The code samples will break out like this:

  • Simple read of Items

  • Reading a Header/Line document such as a Sales Quote.

  • Using Filters to limit the data returned. Sample is Sales Quote for Customer 10000 (The Cannon Group PLC)

  • Create a new Sales Order

  • Overview of Codeunits and other Object Types.

#microsoftdynamicsnav

0 views
Contact Us

Solution Systems, Inc.

3201 Tollview Dr. 

Rolling Meadows, IL 60008

Office: 847-590-3000

Email: info@solsyst.com

Support: 224-345-2020

Support Email: support@solsyst.com

Connect With Us
  • Manufacturing Software | Illinois
  • Manufacturing Software | Illinois
  • Manufacturing Software | Illinois
  • Manufacturing Software | Illinois
  • Manufacturing Software | Chicago
  • Manufacturing Software | Illinois
  • Microsoft Business Podcast
  • Manufacturing Software | Chicago
  • Manufacturing Software | Chicago
  • Manufacturing Software | Chicago
Join our Mailing List

© 2020 Solution Systems, Inc.