- Building ERP Solutions with Microsoft Dynamics NAV
- Stefano Demiliani
- 664字
- 2021-07-09 19:01:57
Publishing NAV web services
Web services can be set up in the Microsoft Dynamics NAV Windows client (RoleTailored Client) or in the Microsoft Dynamics NAV Web client. You must then publish the web service in order to have it available to the client applications.
Users can discover web services by pointing a browser at the computer that is running the Microsoft Dynamics NAV Server and requesting a list of available services.
When you publish a web service, it is immediately available over the network for authenticated users (only users with the correct NAV permissions can access and use published web services).
Creating and publishing NAV web services
To create and then publish a NAV object as a web service, follow these steps:
- Open the Microsoft Dynamics NAV Windows client or the Microsoft Dynamics NAV Web client and, in the Search box, enter
web services
as the keyword and choose the related link: - In the Web Services page, click on New:
- Insert a new record in the table:
- Object Type: Choose the object you want to publish (
Codeunit
,Page
, orQuery
). - Object ID: Select the object ID of the NAV object that you want to expose.
- Service Name: Assign a name for the web service. Please avoid spaces and special characters.
- Published: Click to activate the web service.
- Object Type: Choose the object you want to publish (
- When you publish the web service, in the OData URL and SOAP URL fields, you can see the URLs that are generated for the web service.
- For example, to publish the
Customer Card (Page 21)
object as a web service: - After publishing, NAV gives you the OData URL and SOAP URL for the service.
- If you publish a
Query
object, for example theItem Sales by Customer
query, you have only the OData URL: - If you publish a
Codeunit
object, for example theCost Account Mgt
codeunit: - You have only the SOAP URL.
Checking NAV web services
You can verify the availability of a web service by using a browser and entering the relevant URL, or you can choose the link in the OData URL and SOAP URL fields that you can see in the Web Services page in NAV.
The following table illustrates the types of URL that you can enter in order to have a list of available web services on a NAV instance:

The URL for accessing a page published as a web service has the following syntax:
http://<Server>:<WebServicePort>/<ServerInstance>/WS/<CompanyName>/Page/<ServiceName>
The URL for accessing a codeunit published as a web service has the following syntax:
http://<Server>:<WebServicePort>/<ServerInstance>/WS/<CompanyName>/Codeunit/<ServiceName>
The company name and service name are all case-sensitive. The following table describes the different URL components:
This is a sample of the available web services (discovery
) for this server instance via a browser:

In this sample, you can see that there are two codeunits published as web services for this server instance and this company.
If you type the URL for the first web service codeunit, you can see the published functions (methods) defined in the codeunit as a WSDL definition:

If you publish a page as a web service (for example, Page 21 - Customer Card
), this is the service definition you have by testing on the browser:

For the page, you can also see the native methods exposed to read and update the data:

In a Microsoft Dynamics NAV multitenant deployment, since web services are created in the application database, you must create at least one tenant that has write access to the application database. This setting is determined by the Allow application database writes parameter when you mount a tenant against a Microsoft Dynamics NAV server instance.
Regarding URLs, in multitenant deployments URLs must specify the tenant that the URL applies to (web services are set up in the application database but you need to consume company-specific and tenant-specific data). The URL can specify the tenant ID or the tenant hostname if you specify hostnames as alternative IDs for tenants. For example, http://localhost:7048/DynamicsNAV/OData/Company('CRONUS%20International%20Ltd.')/Customer?Tenant=Tenant1
consumes the Customer OData web service for a specific tenant.
- 一本書學內部審計:新手內部審計從入門到精通
- 新形勢下中國投入產出核算的變革與實踐
- 企業能源審計與節能規劃
- 基本有用的計量經濟學
- 審計實務案例與實訓教程
- 財務建模與綜合估值:數據研磨、模型校準、動態估值
- Salesforce Essentials for Administrators
- PMP備考寶典:路晨帶你去通關
- Oracle Primavera Contract Management,Business Intelligence Publisher Edition v14
- Stata統計分析與行業應用案例詳解(第2版)
- 政策建模技術:CGE模型的理論與實現
- Microsoft SharePoint 2010 Developer’s Compendium:The Best of Packt for Extending SharePoint
- Amazon EC2 Cookbook
- 審計學理論與實務
- 審計學