Publish and Test (SOAP & ODATA WEB-SERVICES) in NAV

Posted on Posted in Microsoft Dynamics NAV


OData web services are a new addition to Microsoft Dynamics NAV, complementing the SOAP web services that have been available since Microsoft Dynamics NAV 2009. Developers planning to create Microsoft Dynamics NAV web services may need to decide which type of web service is best suited for their needs. First, there are some absolute limitations:

  • It is currently not possible to access Microsoft Dynamics NAV “Query objects” with SOAP web services.
  • It is currently not possible to access “CodeUnit Object” with OData web services.
  • “Page Objects” can be accessed by both SOAP and ODATA
  • OData Web Services are much Faster than SOAP.
  • SOAP supports only XML format message. OData Supports XML, JSON messages.
  • SOAP for data exchange, OData for web applications.

SOAP Simple Object Access Protocol

ODATA Open Data Protocol

SOAP Web Services

SOAP web services allow full flexibility for building operation-centric services. They provide industry standard interoperability. Windows Communication Framework (WCF) has supported SOAP services since its initial release in .NET Framework 3.0, and .NET 4. The additional support and default bindings is to make it easier to build SOAP services using WCF.

The most common type of messaging pattern in SOAP is the Remote Procedure Call (RPC), where one network node (the client) sends a request message to another node (the server), and the server sends a response message to the client.

OData Web Services (RESTful Webservice)

OData helps to focus on the business logic while building RESTful APIs without having to worry about the various approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats, query options, etc. OData also provides guidance for tracking changes, defining functions/actions for reusable procedures, and sending asynchronous/batch requests.

OData RESTful APIs are easy to consume. The OData metadata, a machine-readable description of the data model of the APIs, enables the creation of powerful generic client proxies and tools. OData is less suites for applications that primarily RPC-oriented or which data operations are constrained to certain prescribed patterns.

OData supports Representational State Transfer (REST)-based data services which enable resources identified by using Uniform Resource Identifiers (URIs). It is defined in an abstract data model (EDM) to be published and edited by web clients within corporate networks and across the Internet using simple Hypertext Transfer Protocol (HTTP) messages. OData services are lightweight, with functionality often referenced directly in the URI. SOAP web services expose a WSDL document, OData web services expose an EDMX document containing metadata for all published web services.

The extensions to the Atom Publishing Protocol defined in the AtomPub extensions to the OData protocol describe how REST-based data services can enable resources, identified using URIs. And it is defined in an abstract data model (EDM), to be published and edited by web clients within corporate networks and across the Internet using simple HTTP messages.

In addition to the AtomPub format, the OData implementation in Microsoft Dynamics NAV supports the JSON format, a somewhat less verbose format that may perform better in low-bandwidth environments.


In Standard NAV installation, the Web-services are not Activated by Default. So, follow the below procedure to activate the Web-service.

Open Microsoft Dynamics NAV Server -> Open the Instance which we want to publish the Web Service -> Click Edit -> Enable the check box for the required Web Service as Shown below.


The following example illustrates creating a new XML port and Key in the data to Item table through CodeUnit using SOAP Web-service:

Create XML Port:

  1. Open the XML port: NAV Development Environment → Objects → XML Port → New. Also Save the Object as shown below.

2.Add Item Export as Root element in the first row. Add the Item table and indent the row, then add required Item fields as shown below.

3.Set the XML properties, Directions (If Required) and Default Namespaces – YES as shown below.

Run the XML Port from CodeUnit:

  1. As there is no provision to publish XML port in Dynamics NAV, so write a code in the Object codeunit to run the XML port.
  2. Create a function, Item, with Parameters Datatype as XMLport as shown below.

Publish the Code unit in Web Services

  1. Open the RoleTailored NAV client and connect to any company. In the Search box, enter Web services, and then choose the related link. In the Web Services page, on the Home tab, choose New to publish a new SOAP web-service as shown below.

2. Set the Object Type as Codeunit and the Object ID as 60013. And then set the ServiceName as WSDataItemImport. Select Publish – True (So, that SOAPURL is generated automatically. This is the URL to be used for testing). In here the OData URL is “Not Applicable”.


We can Test the Web-services through Testing tools in available in the Internet.

  • Google Chrome Wizdler, which is available as an extension in Chrome store
  • InfoPath Designer, which is part of the Office Pro package
  • WS Studio: a small free tool to make simple tests of the web service
  • Postman, which is a free Google Chrome App for quite advanced test of the web services
  • Through Visual Studio, console application.

Testing the Web Service using Google Chrome Wizdler

Ensure Chrome is installed on your testing machine. To enable Chrome, go to Google Search and type “Wizdler”. Click “Add” to Chrome →Add Extension to enable Wizdler, then reopen the browser. Once Wizdler is added successfully, the icon will be enabled in your browser.

  1. Paste the Soap URL copied from RoleTailored NAV Client in chrome and press Enter. And then Click the Wizdler icon, it will show the available Operations to test as shown below.

2.You will get an XML file structure which you can add or edit the XML files.

3. Once you edit the Xml file with required data, select the required ‘Operation’ and Click ‘GO’.

4. If the Operation is successful, it will insert the data into Item table or else it will throw error.





  1. Open the Role Tailored NAV client and connect to any company.
  2. In the Search box, enter Web services, and then choose the related link.
  3. In the Web Services page, on the Home tab, choose New.
  4. In the Object Type column, select Page. In the Object ID column, enter 21, and in the Service Name column, enter Customer. Select the check box in the Published column.
  5. Choose the OK button.

Check if the endpoint works:

Copy the OData URL to Internet Explorer and press enter. It will display the content as shown below.

Note: Please don’t use OData V4 URL

To View the Customer List Content in XML format, follow the below procedure.

Go to Browser Settings -> Internet Options -> Select Content ->Select Feeds Web Slices Settings.

Below Content shows that the End Point is working.


Leave a Reply

Your email address will not be published. Required fields are marked *