SlideShare a Scribd company logo
1 of 14
Programming with NAV
WebServices –The Basics
Bill Burton
Solution Systems, Inc.
847-590-3000
info@solsyst.com
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.
1. Identify the Page
2. Publish the Web Service
3. Test the URL in a Web Browser
4. Add a Service Reference to Your
Project
5. Write Some Code.
847-590-3000
info@solsyst.com
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.
Any User Interface in NAV can be
published as a Web Service. This
allows you to manipulate data through
Web Services as if you were using
NAV itself.
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.
847-590-3000
info@solsyst.com
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.
847-590-3000
info@solsyst.com
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.
847-590-3000
info@solsyst.com
Publish the Web Service
This is the easy part.
Navigate 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 in 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.
847-590-3000
info@solsyst.com
Test the URL in a Web Browser
This is the pattern for your Web
Service URL:
http://<Server>:<WebServicePort>/<S
erverInstance>/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.
847-590-3000
info@solsyst.com
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
article, 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.
847-590-3000
info@solsyst.com
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.
847-590-3000
info@solsyst.com
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:
http://192.168.10.12:7047/commercer2
/WS/CRONUS%20Supply,%20Inc/Pag
e/Item
847-590-3000
info@solsyst.com
If you open that in a Web Browser and
everything has been set up properly,
you will get this XML to the right in reply
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.
847-590-3000
info@solsyst.com
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 simpleASP.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
Reference…
847-590-3000
info@solsyst.com
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.
847-590-3000
info@solsyst.com
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 separate 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.
References
MSDN Reference “How to build a URL”: http://msdn.microsoft.com/en-us/library/dd355398.aspx
Want More Microsoft
DynamicsTips?
View My Blog
847-590-3000
info@solsyst.com

More Related Content

Viewers also liked (7)

Ax 2012 x++ code best practices
Ax 2012 x++ code best practicesAx 2012 x++ code best practices
Ax 2012 x++ code best practices
 
Presentacion Dynamics NAV 2015
Presentacion Dynamics NAV 2015Presentacion Dynamics NAV 2015
Presentacion Dynamics NAV 2015
 
Upgrading Microsoft Dynamics NAV
Upgrading Microsoft Dynamics NAVUpgrading Microsoft Dynamics NAV
Upgrading Microsoft Dynamics NAV
 
NAV 2016 Workflow
NAV 2016 WorkflowNAV 2016 Workflow
NAV 2016 Workflow
 
X++ advanced course
X++ advanced courseX++ advanced course
X++ advanced course
 
Microsoft Dynamics NAV 2016: what's new
Microsoft Dynamics NAV 2016: what's newMicrosoft Dynamics NAV 2016: what's new
Microsoft Dynamics NAV 2016: what's new
 
Vendor Landscape: Mid-Market ERP
Vendor Landscape: Mid-Market ERPVendor Landscape: Mid-Market ERP
Vendor Landscape: Mid-Market ERP
 

More from Solution Systems, Inc.

More from Solution Systems, Inc. (20)

5 Things to Consider When Upgrading Microsoft Dynamics NAV
5 Things to Consider When Upgrading Microsoft Dynamics NAV5 Things to Consider When Upgrading Microsoft Dynamics NAV
5 Things to Consider When Upgrading Microsoft Dynamics NAV
 
Three Most Common Realizations that it's Time to Upgrade Your Business Software
Three Most Common Realizations that it's Time to Upgrade Your Business SoftwareThree Most Common Realizations that it's Time to Upgrade Your Business Software
Three Most Common Realizations that it's Time to Upgrade Your Business Software
 
Dynamics 365 for Financials vs. NetSuite
Dynamics 365 for Financials vs. NetSuiteDynamics 365 for Financials vs. NetSuite
Dynamics 365 for Financials vs. NetSuite
 
Microsoft Dynamics 365 for Financials FAQ
Microsoft Dynamics 365 for Financials FAQMicrosoft Dynamics 365 for Financials FAQ
Microsoft Dynamics 365 for Financials FAQ
 
Microsoft Dynamics NAV 2017 - Complete list of client enhancements for end users
Microsoft Dynamics NAV 2017 - Complete list of client enhancements for end usersMicrosoft Dynamics NAV 2017 - Complete list of client enhancements for end users
Microsoft Dynamics NAV 2017 - Complete list of client enhancements for end users
 
Microsoft Dynamics NAV 2017 - Simplified setup
Microsoft Dynamics NAV 2017 - Simplified setupMicrosoft Dynamics NAV 2017 - Simplified setup
Microsoft Dynamics NAV 2017 - Simplified setup
 
Microsoft Dynamics NAV 2017 - Item attributes
Microsoft Dynamics NAV 2017 - Item attributesMicrosoft Dynamics NAV 2017 - Item attributes
Microsoft Dynamics NAV 2017 - Item attributes
 
Microsoft Dynamics NAV FAQ II
Microsoft Dynamics NAV FAQ IIMicrosoft Dynamics NAV FAQ II
Microsoft Dynamics NAV FAQ II
 
Microsoft Dynamics NAV FAQ III
Microsoft Dynamics NAV FAQ IIIMicrosoft Dynamics NAV FAQ III
Microsoft Dynamics NAV FAQ III
 
Microsoft Dynamics NAV FAQ IV
Microsoft Dynamics NAV FAQ IVMicrosoft Dynamics NAV FAQ IV
Microsoft Dynamics NAV FAQ IV
 
Microsoft Dynamics NAV FAQ 5
Microsoft Dynamics NAV FAQ 5Microsoft Dynamics NAV FAQ 5
Microsoft Dynamics NAV FAQ 5
 
Does Your Controller Know?
Does Your Controller Know? Does Your Controller Know?
Does Your Controller Know?
 
Does Your Owner or CEO Know?
Does Your Owner or CEO Know?Does Your Owner or CEO Know?
Does Your Owner or CEO Know?
 
Does Your Sales Manager Know...
Does Your Sales Manager Know...Does Your Sales Manager Know...
Does Your Sales Manager Know...
 
Top 3 Time Saving Features of Microsoft Dynamics NAV
Top 3 Time Saving Features of Microsoft Dynamics NAVTop 3 Time Saving Features of Microsoft Dynamics NAV
Top 3 Time Saving Features of Microsoft Dynamics NAV
 
17 New Application Changes in Microsoft Dynamics NAV
17 New Application Changes in Microsoft Dynamics NAV17 New Application Changes in Microsoft Dynamics NAV
17 New Application Changes in Microsoft Dynamics NAV
 
Project Madiera Overview
Project Madiera OverviewProject Madiera Overview
Project Madiera Overview
 
Microsoft Dynamics Customer Stories
Microsoft Dynamics Customer StoriesMicrosoft Dynamics Customer Stories
Microsoft Dynamics Customer Stories
 
The History of Microsoft Dynamics NAV
The History of Microsoft Dynamics NAVThe History of Microsoft Dynamics NAV
The History of Microsoft Dynamics NAV
 
What are the benefits of implementing NAV?
What are the benefits of implementing NAV? What are the benefits of implementing NAV?
What are the benefits of implementing NAV?
 

Recently uploaded

Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 

Recently uploaded (20)

A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdfMicrosoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
Microsoft 365 Copilot; An AI tool changing the world of work _PDF.pdf
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024IT Software Development Resume, Vaibhav jha 2024
IT Software Development Resume, Vaibhav jha 2024
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 

Programming With NAV Web Services – The Basics

  • 1. Programming with NAV WebServices –The Basics Bill Burton Solution Systems, Inc. 847-590-3000 info@solsyst.com
  • 2. 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. 1. Identify the Page 2. Publish the Web Service 3. Test the URL in a Web Browser 4. Add a Service Reference to Your Project 5. Write Some Code. 847-590-3000 info@solsyst.com
  • 3. 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. Any User Interface in NAV can be published as a Web Service. This allows you to manipulate data through Web Services as if you were using NAV itself. 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. 847-590-3000 info@solsyst.com
  • 4. 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. 847-590-3000 info@solsyst.com
  • 5. 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. 847-590-3000 info@solsyst.com
  • 6. Publish the Web Service This is the easy part. Navigate 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 in 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. 847-590-3000 info@solsyst.com
  • 7. Test the URL in a Web Browser This is the pattern for your Web Service URL: http://<Server>:<WebServicePort>/<S erverInstance>/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. 847-590-3000 info@solsyst.com
  • 8. 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 article, 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. 847-590-3000 info@solsyst.com
  • 9. 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. 847-590-3000 info@solsyst.com
  • 10. 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: http://192.168.10.12:7047/commercer2 /WS/CRONUS%20Supply,%20Inc/Pag e/Item 847-590-3000 info@solsyst.com
  • 11. If you open that in a Web Browser and everything has been set up properly, you will get this XML to the right in reply 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. 847-590-3000 info@solsyst.com
  • 12. 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 simpleASP.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 Reference… 847-590-3000 info@solsyst.com
  • 13. 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. 847-590-3000 info@solsyst.com
  • 14. 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 separate 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. References MSDN Reference “How to build a URL”: http://msdn.microsoft.com/en-us/library/dd355398.aspx Want More Microsoft DynamicsTips? View My Blog 847-590-3000 info@solsyst.com