Business Central Web Services: Page vs Codeunit vs Query Differences

 

Business Central Web Services

Business Central supports three types of web services: API, SOAP, and OData.

Developers can create and publish functionality as web services, where they expose pages, codeunits, or queries, and even enhance a page web service by using an extension codeunit. When Business Central objects are published as web services, they're immediately available on the network.

Comparing APIs, SOAP and OData Web Services

Developers planning to create Business Central web services may need to decide which type of web service is better suited to their needs. The following table shows the types of web service applications that you can create for the web service protocols.

ObjectSOAP web servicesOData web servicesAPI web service
PagesYes: Create, Read, Update, and Delete operations (CRUD)Yes: Create, Read, Update, and Delete operations (CRUD)Yes: Create, Read, Update, and Delete operations (CRUD)
CodeunitsYesYes (through OData unbound actions)No, not yet
QueriesNoYes: Read-onlyYes: Read-only

Business Central supports API and OData web services in addition to the SOAP web services that have been available since Microsoft Dynamics NAV 2009.

Page Web Services

When you expose a page as an OData web service, you can query that data to return a service metadata (EDMX) document, an AtomPub document, or a JavaScript Object Notation (JSON) document. You can also write back to the database if the exposed page is writable. For more information, see OData Web Services.

Page-based web services offer built-in optimistic concurrency management. Each operation call in a page-based web service is managed as a single transaction.

You can use extension codeunits to extend the default set of operations that are available on a page. Adding an extension codeunit to a page is useful if you want to perform operations other than the standard Create, Read, Update, and Delete operations. The benefit of adding an extension codeunit to a page is that you can make the web service complete by adding operations that are logical to that service. Those operations can use the same object identification principle as the basic page operations.

Codeunit Web Services

Codeunit web services provide you with the most control and flexibility. When a codeunit is exposed as a web service, all functions defined in the codeunit are exposed as operations. Both OData and SOAP can be used with codeunit web services.

Query Web Services

When you expose a Business Central query as an OData web service, you can query that data to return a service metadata (EDMX) document or an AtomPub document. For more information about how to create and use Business Central queries, see Query Object.

3 comments:

  1. Do you have any criteria to determine whether I need to create a page or a query.

    ReplyDelete
  2. "Financial management is the backbone of any successful business." https://www.cpkelly.com/

    ReplyDelete
  3. "Strategic planning is essential for guiding a business towards its long-term goals." https://www.cpkelly.com

    ReplyDelete