How to Publish and Test Webservices in Dynamics NAV?

This topic contains 2 replies, has 3 voices, and was last updated by  John 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12062

    Andrew Jenson
    Participant

    How to Publish and Test Webservices in Dynamics NAV?

    #12509

    Lee Min
    Participant

    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.

    nav
    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.

    codes
    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.

    codes
    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.

    table
    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

    #12864

    John
    Participant

    Hi Andrew,

    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.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Skip to toolbar