Webservices in Business Central - SOAP and OData

There are two types of web services in Dynamics 365 Business Central ™ (Navision): SOAP and OData. For a question, which one would be better, the correct answer could be "depending on":

  • Depending on what we want to do with the webservice,
  • Depending on the data volume in question,
  • Depending on the direction of communication (Navision is exposed as the web service or is the other system exposed via the web service to Business Central)
  • And many other aspects of the communication architecture.

It would be just unfair and too simplistic to say "SOAP is fixed, dead. Now almost everything is connected via REST-Api". The two types of web services are used for different tasks. Roughly speaking, the SOAP is mostly used where operations or tasks should be exposed. REST/OData (OData is a standardization of REST) ​​is used where the resources should be exposed. The most important differences are summarized in the following table.

Dynamics 365 Business Central - Comparison of OData and SOAP

Some additional comments about using web services in Navision:

  • In older Versions of Dynamics NAV Pages were impractical for web services. XML ports were better (too complicated and confusing in the code for a long time). Currently all has changed. There is a pageart 'API'. This type of page cannot be displayed in the user interface, but is intended for building reliable integration services.

Dynamics 365 Business Central (Navision) - Page Type: API

  • OData includes a query language (Synthax example ...$filter=No eq '0001'&$select=No,Name)
  • A handy OData communication method in AL code: .NET Library HttpClient:
    • GET: HttpClient . GetAsync(method) . Result
    • POST: HttpClient . PostAsync(method,httpContent) . Result
    • PUT: HttpClient . PutAsync(method,httpContent) . Result
    • DELETE: : HttpClient . DeleteAsync(method) . Result
  • The HttpClient method runs asynchronously in AL. To be in sync, the method HttpResponseMessage . EnsureSuccessStatusCode() should be used.

Setting up Web Services in Business Central

In the demo version of Business Central, some good examples of web services have already been set up. They can be listed quickly in the search field (Alt + Q)

Dynamics 365 Business Central (Navision) - Wiei möchten Sie weiter verfahren Seite

On the list of existing web services, we select the "Chart of accounts". There are URLs to web services in the last three columns.

Dynamics 365 Business Central (Navision) - Webdiensten Seite

Before the link can be called, it still has to be checked whether the SOAP or OData web services are allowed. These can be set up with the PowerShell Commandlet or manually in BC Administration. If an error occurred while switching on 'Die URL-Reservierung konnte nicht hinzugefügt werden. Fehler: 87 Falscher Parameter.', It may be, the name used has not allowed character (in our example we used a local user in our test environment - which normally is not the case - 'Konrad Seccount').

Dynamics 365 Business Central (Navision) - Administration - Fehler beim Aufruf der Webdienst

Not the nicest solution, but we have adjusted the name accordingly in "Local users and groups" with Command lusrmgr.msc.

Lokale Benutzer und Gruppen Fenster

After restarting the service, the web services can be called with the link. Then we are asked for an authentication.

Log in zu Webdienst in Dynamics 365 Business Central (Navision)

And then the page will access as SOAP.

SOAP Example

SOAP Beispiel in Dynamics 365 Business Central (Navision)

Existing methods in the SOAP Web services:

  • Codeunits: all functions with parameters
  • XML-Ports: As a parameter in the function in the Codeunit
  • Pages:
    • Create
    • CreateMultiple
    • Read
    • ReadMultiple
    • Update
    • UpdateMultiple
    • Delete
    • IsUpdated
    • ReadByRecID
    • GetRecIDFromKey
    • Delete_<PagePartName>
ODATA Example

URL: http://x2:15048/BC150/OData/Company('CRONUS%20AG')/Kontenplan. Result:

REST OData Beispiel in Dynamics 365 Business Central (Navision)

Microsoft REST API Development Guidelines are available at this Link. In our next step filters are set to show some of OData's most important features - the query possibilities. For this we need the following filter operations:

ODATA REST Filter Operationen

And an example with a REST Api REQUEST. Structured URL Request: http://x2:15048/BC150/OData/Company('CRONUS%20AG')/Kontenplan?$filter=No eq '0001'&$select=No,Name. The result:

Gefilterte OData REST Webdienst in Dynamics 365 Business Central (Navision)

An example of how to build a REST OData web service in Business Central is shown in this post.

Dynamics 365 Business Central TM (Navision) Developer and Consultant View Konrad Buczkowski's LinkedIn profile Konrad Buczkowski