Monday, September 4, 2023

RESTful WebServices

Here, I am going to explain RESTful web service invocation and fetch Database-records.

There are three scenarios included here..

1. GET Method: Fetch employee details from Database

2. Post Method: Add employee details into a Database Table

3. Delete Method: To delete a particular record from the table.

First, create HTTP Connection, Database connection(MySQL)

HTTP Connection:

DB Connection:

Schema : 

Get Method - Implementation flow

This flow will fetch the db records based on query parameter<eid>

            Business Process


Start Activity

JDBC Query


Render JSON

This activity converts from DB format to JSON format

End Activity

Post Method - Implementation flow

This process will create a new record in DB table based on given payload


Start Activity


Parse JSON

Update JDBC Activity


Render JSON

This activity converts the given input to JSON format



End Activity

Delete Method - Implementation flow

This flow will delete db records based on query parameter <eid>


Start Activity

Delete Emp Details (Update JDBC)

Mapper Activity

End Activity

Orchestration- RESTful Service -Implementation (Main Flow)

This flow acts as a gateway to receive request and route it based on the base path and HTTP Method.

HTTP Receiver Activity

Rest Dispatch and Reply



Resource path
Under Service Editor Tab>On "Application" -Right click and add RestResource->Resource Path and Query Parameters. And, then add HTTP methods as shown below..


POST Method
Binding 

GET Method
Bindings
Delete Method


Bindings

REST Dispatch and Reply (Overview) - to check resource path and business process


DB:
Testing:
Use Postman / SoapUI to test the application

GET Method: 
POST Method:
Delete Method:


Source Code: 

Thanks for your time :-)

1 comment:

XML Palette Activities

The XML palette provides activities for parsing XML strings into schemas and rendering schemas into XML strings Parse XML: Parse XML  is use...