Reply To: How to Publish and Test Webservices in Dynamics NAV?

Network of MS Dynamics D365, AX, NAV, GP, SL, CRM, RMS, POS professionals Forums Reply To: How to Publish and Test Webservices in Dynamics NAV?


Lee Min

< ![CDATA[Hi Andrew, 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.
nav table
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 Environment

Skip to toolbar