Network of MS Dynamics D365, AX, NAV, GP, SL, CRM, RMS, POS professionals › Forums › Microsoft Dynamics NAV / Navision › NAV Installation & Administration › How to Publish and Test Webservices in Dynamics NAV?
February 21, 2019 at 4:33 am #12062
How to Publish and Test Webservices in Dynamics NAV?February 26, 2019 at 4:46 am #12509
Publishing and testing web services in Dynamics NAV or Business Central is a necessary task and can be very simple by following these instructions.
Create an XML Port for Customer
The following example illustrates creating a new XML port and adding required customer fields:
1. Open the XML port: NAV Development Environment → Objects → XML Port → New.
2. Add XMLRoot as an element in the first row.
3. Add a Customer table and indent the row, then add the required customer fields.
Figure 1 – Dynamics NAV / Business Central Customer Table
4. Set the XML properties, Directions: Import, encoding: UTF-8 and Default Namespaces – YES.
Figure 2 – Setting Optional Fields in Dynamics NAV and Business Central
Run the XML Port from the Codeunit
1. There is no provision to publish XML port in Dynamics NAV/BC, so write code in the Object codeunit to run the XML port.
2. Create a function, ImportCustomer, with Parameters XMLport and StatusText Variable.
Figure 3 – Import Customer Function in Dynamics NAV or Business Central
Publish the Codeunit in Web Services
1. Open Web services: Go to → Web Services page from Search.
2. Click “New” to create new Webservice records.
3. Set the Object Type as Codeunit.
4. Set the Object ID as 50001.
5. Set the ServiceName as ImportCustomer.
6. Publish – True (SOAP URL has generated automatically. This is the URL to be used for testing).
Figure 4 – Publishing a Codeunit in Web Services for Dynamics NAV or Business Central
Test Using Chrome Wizdler
1. Ensure Chrome is installed on your testing machine.
2. To enable Chrome, go to Google Search and type “Wizdler”.
3. Click “Add” to Chrome →Add Extension to enable Wizdler, then reopen the browser.
4. Once Wizdler is added successfully, the icon will be enabled in your browser.
Figure 5 – Chrome with Wizdler Enable (icon highlighted in lower right of image)
5. Paste the Soap URL copied from NAV/BC.
6. Click the Wizdler icon as shown in Figure 5.
7. You will get an XML file structure, and you can add or edit the XML files.
Figure 6 – XML File Structure
8. Fill the required values and click “GO” from the Wizdler. You will receive an acknowledgment.
Figure 7 – Acknowledgement from Wizdler
Enable Debug from NAV/BC Administration
1. Open NAV/BC Application administration and select the service NAV. “Enable Debugging” should be enabled in the General tab.
Figure 8 – Dynamics NAV and Business Central Application Administration with ‘Enable Debugging’ Enabled
2. Open the Debug Session Mode from the development environment. and activate “Debug Next”.
Figure 9 – Debug Session Mode in the Dynamics NAV or Business Central Development EnvironmentMarch 11, 2019 at 6:44 am #12864
To create and publish a web service
1. Open the Microsoft Dynamics NAV Windows client or the Microsoft Dynamics NAV Web client.
2. In the Microsoft Dynamics NAV Windows client, in the Search box, enter Web Services, and then choose the related link.
In the Microsoft Dynamics NAV Web client, choose the Search for Page or Report button, enter Web Services, and then choose the related link.
3. In the Web Services page, choose New.
4. In the Object Type column, select Codeunit, Page, or Query.
5. In the Object ID column, select the object ID of the object that you want to expose. For example, to expose the customer card as a web service, enter 21.
If the database contains multiple companies, you can choose an object ID that is specific to one of the companies.
6. In the Service Name field, assign a name to the web service. For example, if you expose the customer card as a web service, enter Customers.
7. Select the checkbox in the Published column.
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. You can test the web service immediately by choosing the links in the OData URL and SOAP URL fields. Optionally, you can copy the value of the field and save it for later use.
After you publish a web service, it is available on the Microsoft Dynamics NAV Server computer that you were connected to when you published. The web service is available across all Microsoft Dynamics NAV Server instances running on the server computer.
You can verify the availability of that web service by using a browser, or you can choose the link in the OData URL and SOAP URL fields in the Web Services window. The following procedure illustrates how you can verify the availability of the web service for later use.
You must be logged in to reply to this topic.