What is Web Service?
A web service is a generic term for an interoperable machine-to-machine software function that is hosted at a network addressable location.
This is a network accessible interface to application functionality/code using the standard internet technologies. And which provides an abstract layer between the client side application and application code. This allows for cross platform interoperability in a way that makes the platform irrelevant.
Web Service architecture:
The major concept in Web Services are encapsulation, message passing, dynamic binding, and service description and querying & API for use by other services on the network and encapsulating implementation details. Web Service architecture majorly describes three types of roles. Which are Service Provider, Service Requester and Service Broker. And also provides following operations as publishing the service, finding & invoking the service.
Each of these components is described as a service in Web service architecture, which provides the behavior via an existing API for invoking over a network. This is a logical evolution of object oriented approach to e-business. Service Providers will publish the services to a service broker and Service requester will find the respected services using a service broker & to bind them. The key for Just-In-time integration is that this can happen at any time, particularly at run time.
Following are some of the essential activities which need to happen in any of the service-oriented environment:
- A web service needs to be created, and need to invoke the respected methods and its interfaces.
- A web service needs to be published to one or more repositories, in order to locate the potential users.
- A web service can also be unpublished when it is no longer usable or needed.
Publish REST API in Mendix Platform:
Mendix low code platform supports multiple ways to publish the data from one application to other applications. REST publish is one of the easiest way to create API’s using Mendix. Using Published REST service, we can able to expose the data from one to other applications, by mapping the microflow as a web service operation. GET method, allows information sharing between my application and other applications, where the other system can determine when to retrieve that shared information.
Which allow us to generate Json and xml messages from domain model, documents the resources & operations of API and which includes Open API/Swagger. This output enables us to share the API’s which we have created. By default REST api’s will exchange json/xml messages. In order to define these messages, desktop modeler in Mendix provides Message definitions, for this no need of defining json snippet or xml schema manually. Similarly, for rest of the methods (Post/Put/Patch/Delete/Head/Options) need to process the rest service operations.
Mendix provides different ways to provide authentication credentials to externals services, like basic HTTP authentication, custom authentication service and client certificates for authentication along with services. We can also send and receive binary data or file documents, for example retrieving the PDF documents.
Testing the API: Once we deploy Rest api, need to open web browser and navigate to the following link, with respect to the port number http://localhost:8080/rest-doc
To know more details, just click here: https://docs.mendix.com/howto/integration/expose-a-web-service
Consume REST API in Mendix Platform:
Mendix low code platform supports number of ways to consume the data from one application to other applications, by calling the ‘Call REST service’ action in microflow. So we can retrieve all the published data from the published data applications. POST method which exports the information to a Json String value, change the HTTP response object and create an HTTP header object. The easiest way to consume the rest api is, by creating the Json structure by adding Json format message, Mendix will automatically determine the structure of your message and the applicable attribute types. And then we need to define the mappings to import and export data to the external rest service. In the request and response tabs of REST service activity we can define the mappings which we prefer. In the Rest service activity, provide the url of published api application.
To know more details, just click here: https://docs.mendix.com/howto/integration/consume-a-complex-web-service
Error Handling In REST API:
Mendix provides Errors handling mechanism on Rest activity, using this operation we can get to know the status of ‘Latest Http Response’ object. If it is not successful we can able to track the error from ‘Latest Http Error’ object.
Following are the types of error handlers on REST activity:
- Custom with Roll back: The changes which are happened before occurring the error will revert back. Only the changes which are executed in the error handling flow will get executed.
- Custom without Roll back: The changes which are happened before occurring the error will remain same and the microflow will proceeds over the custom error handler flow.
- Rollback: Which reverts all of the changes until the last time the object was committed.
Scope of Mendix Web Service in data transfer:
- Which is involved in sharing data among dependency applications as a service will define as Web Service.
- Most of the dependent applications need some required data from other applications, sharing data is a bit complex from one application to another applications. So, by using REST Web service operations in Mendix, we can publish the data in master side applications and can consume the published/exposed data in required applications.
- We can control the sharing data by using JSON structure or Message Definition in both sides of applications.
- Exposing the binary type data is a bit complex in Mendix Rest service, still it can be achievable with Encrypt/Decrypt java actions in Mendix platform.
- Mendix made Rest service very easy using commit on REST action itself, we can commit the data without retrieve from mapping if both side using same entities.
Mendix low code platform is the fastest and easiest platform to build and continuously improve mobile and web applications that enable innovation at web scale. And for the development that provides a comprehensive and integrated set of tools for the entire application lifecycle.