Publishing and Testing Webservices in Microsoft Dynamics NAV or Business Central

Publishing and Testing Webservices in Microsoft Dynamics NAV or Business Central

 

Publishing and testing webservices 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 element in the first row.
  3. Add a Customer table and indent the row, then add required customer fields. Figure 1 - Dynamics NAV / Business Central Customer Table

Figure 1 – Dynamics NAV / Business Central Customer Table

  1. Set the XML properties, Directions: Import, encoding: UTF-8 and Default Namespaces – YES.

Figure 2 - Setting Optional Fields in Dynamics NAV and Business Central
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 a 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
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 (SOAPURL is 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
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)
Figure 5 – Chrome with Wizdler Enable (icon highlighted in lower right of image)

  1. Paste the Soap URL copied from NAV/BC.
  2. Click the Wizdler icon as shown in Figure 5.
  3. You will get an XML file structure, and you can add or edit the XML files.
    Figure 6 - XML File Structure
    Figure 6 – XML File Structure
  4. Fill the required values and click “GO” from the Wizdler. You will receive an acknowledgement.
    Figure 7 - Acknowledgement from Wizdler
    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
Figure 8 – Dynamics NAV and Business Central Application Administration with ‘Enable Debugging’ Enabled

  1. Open the Debug Session Mode from development environment. and activate “Debug Next”.
    Figure 9 - Debug Session Mode in the Dynamics NAV or Business Central Development Environment
    Figure 9 – Debug Session Mode in the Dynamics NAV or Business Central Development Environment

Trending Posts

Stay Informed

Choose Your Preferences
First Name
*required
Last Name
*required
Email
*required
Subscription Options
Your Privacy is Guaranteed