Today in this post we will continue from where we left our previous post, if you missed or wish to have a look you can find her in this link.
Web Services – Business Central Part- 1
We saw in our previous post, you expose an OData service that can be accessed from a URL by using a web browser or any other HTTP client.
You need the URL of the OData page or query web service
If you use the attribute ?$format=atom you will get an AtomPub document
If you use the attribute ?$format=json you will get an JSON document
You can obtain service metadata documents for either page or query web services.
SOAP Web Services
If your client requests another transport protocol than HTTP or HTTPS, then you can use SOAP as it also supports, for example, SMTP.
Microsoft is heavily investing in REST and OData, and certainly with the online apps like Power BI, PowerApps, and others. So at this point SOAP isn’t the primary choice for web services anymore.
We can find the available SOAP web services at the same page where we define the OData web services.
If we go to the search box and then search for web services, This page is used to enable access to OData and SOAP web services.
We could enable OData web services only with the object types of query and pages, and for SOAP web services, we can only enable it for pages and codeunits and not for queries.
For example soap url for my Customers Service will be as below:
You can find some post related to consuming web service and working with web service for older versions but it can be used with business central too.
Exposing & Consuming the Web service from & inside Navision – Part-1
Exposing & Consuming the Web service from & inside Navision – Part-2
Exposing & Consuming the Web service from & inside Navision – Part-3
Exposing & Consuming the Web service from & inside Navision – Part-4
When you are exposing your object for web service, ensure that you use GUIAllowed function to supress the UI. Encapsulate the code that could cause in error, not your entire code.
Also the exceptions must be handled in order to facilitate that your web service don’t end the execution unexpectedly.
You must check with the GuiAllowed function when you are using one of the following dialog functions:
Close, Confirm, Error, Open, StrMenu, Update
The Message function is the only dialog function that doesn’t cause an exception.
Other keywords that you shouldn’t use are:
Page.Run, Page.RunModal, Activate, Report.Run, Report.RunModal, Hyperlink, File.Upload, File.Download
Hope you got some insight on Web Services.
I will come up with more features in other posts, till then keep exploring and learning, and take care of yourself.
You must be logged in to post a comment.