Friday, March 31, 2023

Configuring A REST Service

 Service-REST

    RESTRepresentational State Transfer 

  Stateless and Light Weight

What is stateless? – Stateful is like somewhere you maintain the session. When you say stateless you don’t maintain the session. When you create a case, case data is getting saved to the database so, some transactions are there. But in REST you don’t do that you hit the service and get the data. That’s it.

  1.  Uses the HTTP protocol and perform CRUD operations using HTTP methods
  2.   Can use XML, JSON, HTML
  3.  REST APIs uses URI to identify the resource (That is called resource-based )


HTTP methods

 

GET method

Can help with retrieving data/Resource – Similar to Obj-Browse method

E.g.: - GetCustomerDetails

 

POST method

Can help with creating resource

E.g.: -CreateClaimsRequest

(Must define the body)

 

PUT method

Can help with updating a record

E.g.: - UpdateClaimsRequest

(There is no much difference in PUT and POST methods as both methods need to define an activity which will determine what needs to be done)

 

DELETE method

Can help with deleting resource – in a way similar to GET method as it doesn’t need a body

E.g.: - DeleteFraudDetails

 

PATCH method –

Can help with partial updating resource

E.g.: -UpdateCustomerAddressDetails


Why REST is preferred over SOAP?

  1. REST messages are more light-weight than SOAP
  2. REST supports many message formats such as JSON,XML and HTTP but SOAP only supports XML.
  3. REST exposes service URI where as SOAP exposes the user interface.
  4. REST supports different HTTP methods where SOAP supports only POST

Steps to implement Service-REST

  1. Decide on application layer (situational layering).
  2. Create an integration data model (classes and properties).
  3. Create the service processing activity
  4. Create the service package (optional).
  5. Create the service-REST rule.

Example - Create a Service REST using GET method

Step 1


Here we need to decide if the integrations/services are common to all apps in the organization (if so, define it org layer as "Org-Int-Service") or if they are specific to the application ("Org-App-Int-Service")

Step 2


Creating the integration class

Note this newly created class is an abstract class as we don't need to maintain any data table instances.

Now we are going to create create classes to generate a JSON response look like below

{
"FraudType":"Invalid Document",
"CustomerID":"C-12345",
"CustomerName":"Tehan Muhandiramge"
"PolicyType":"Auto"
}

Now we need to create properties to hold response properties inside the integration class


Here we can reuse existing data classes when defining properties


Step 3

Create the service activity inside integration class.






Refer the data page and set the properties to Response clipboard page

(Additional note - when we execute the activity manually in the standard thread the data page results can be seen in RunRecordPrimayPage)


Step 4

Create the REST Service by navigating Create menu > Integration-Services > Service-REST


Define the activity and parameters as follows


Now configure the response tab as follows 


Note:- When "Use fast Processing" option selected Obj-class also will be sent in the response.

Now you can run the service using the service rule form or Postman and run the tracer



Note :- Check how to set username and password for Basic Auth




Rule Delegation

 Summary of Rule Delegation The purpose of Rule Delegation is to make the rule available in the production environment for customization for...