Web services

Starting from Microsoft Dynamics NAV 2009, it was possible to publish page and codeunit objects as web services to allow external applications to access Dynamics NAV data and business logic. In the later releases of Microsoft Dynamics NAV, it is also possible to publish Query objects as web services.

Page and codeunit objects can be accessed through SOAP (Simple Object Access Protocol) web services. Queries can only be accessed through the OData web services protocol.

You will need to first enable the SOAP and OData services from the Dynamics NAV Administrator.

  1. Start the Dynamics NAV 2016 Administrator from the start menu.
  2. Click on the service that's running Dynamics NAV. If you did the full installation, the default service should be DynamicsNAV90.
  3. Select the service and click on Edit.
  4. Place a checkbox on the Enable SOAP Service and Enable OData Service.
  5. Click on Save after you're done:
    Web services

To publish a query as a web service from Dynamics NAV, perform the following steps:

  1. Open the Windows client for Microsoft Dynamics NAV.
  2. Navigate to Departments | Administration | IT Administration | General.
  3. Select Web Services.
  4. Select New on the ribbon bar to publish a new web service.
  5. The New-Web Services page will open.
  6. Select Query as Object Type.
  7. Enter 50000 in the Object ID field.
  8. Enter a name in the Service Name field. For example, let's use MyQueryWS as Service Name.
  9. Check the Published field, as shown in the following screenshot:
    Web services

At this point, the query is already published as a web service. You can check to see if it is accessible using your browser by clicking on OData URL, and then clicking on the hyperlink symbol or copying and pasting the URL to your web browser.

Web services

Note

Note that if you're using the Windows Edge browser from Windows 10, the web service will not display. You will only be able to run using Internet Explorer, Google Chrome, or other full browsers.

External applications

Because Dynamics NAV queries can be published as web services, they can be accessed by absolutely any application that can consume OData web services. It can be an external application developed by you for the only purpose of reading Dynamics NAV data or it can be a commonly used application that supports OData web services.

If you are integrating NAV with an external app via web services, it's always recommended not to expose directly the NAV web services but use a custom WS that talks with NAV (via standard web services exposed as described) and the external system.

In this section we will see how to use Dynamics NAV queries in Microsoft Office Excel.

Excel and PowerPivot

Among all the applications that are out there, an extensively used one is probably Microsoft Office Excel. There is a free add-in for Excel called PowerPivot that can consume OData web services.

We can do that as follows:

  1. If you're using Excel 2013, you can enable the PowerPivot 2013 by going to the Add-in page from the Options menu. Or you can download PowerPivot by performing a quick search on the Internet, which will lead you to the download page.
  2. The installation of PowerPivot will create a new tab in the ribbon bar of Microsoft Office Excel.
    Excel and PowerPivot
  3. Open Microsoft Excel 2013.
  4. On the POWERPIVOT tab, select Manage.
  5. Select Get External Data | From Data Service | From OData Data Feed.
  6. You will be asked to enter a friendly connection name and a data feed URL. Enter NAVMyQueryWS as Friendly connection name and copy and paste the OData URL from the Dynamics NAV web service screen, or you can type in the following path as the value for Data Feed URL:

    http://localhost:7048/DynamicsNAV90/OData/Company('CRONUS%20USA%2C%20Inc.')/MyQueryWS

    Excel and PowerPivot
  7. Click on Test Connection to check if PowerPivot can access the published web service.
  8. Click on Next and then click on Finish.
  9. An import process will start. Once it is finished, click on Close.
  10. The imported data will be displayed on the PowerPivot for Excel window.
    Excel and PowerPivot
  11. Select PivotTable, and a PivotTable that uses data from Microsoft Dynamics NAV will be created. Select the fields that you want to see on the PivotTable.
    Excel and PowerPivot
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.199.243