Discussion
Adqura
GB
Last activity: 2 Nov 2016 8:57 EDT
REST Service Integration Guide / Tutorial
Hi,
I found a some of info around REST Connector Integration (https://pdn.pega.com/integration/create-and-test-soap-sap-and-rest-data-sources#createrest) but not much on REST Service Integration.
Is there a guide, tutorial or an article that decribes an end to end PRPC REST Service Integration preferably using json as the data interchange format?
Many thanks
Suraj
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Pegasystems Inc.
US
The PDN as well as the Pega 7 Platform product help are both your best resources for information on REST service integration. Of course, post comments on the forum as well for any specific issues you're facing.
Adqura
GB
Ok, sounds good. I think we will have a full guide by the end of this forum topic. I hope I could use this topic as a sounding board of sorts.
Should I go down the: Designer Studio => Integration => Services => Service Wizard (Service Purpose: Invoke existing activity Rules & Service Type: HTTP) route or Create a new Service REST rule manually by selecting Service REST from the Integration-Services category in the Records explorer? What's the difference between the 2 approaches? And which one's easier?
Here's what I've figured so far.
As per the Pega 7 Platform Product Help for Service HTTP rules - https://community.pega.com/sites/default/files/help_v71/procomhelpmain.htm - 'A low-overhead stateless alternative to SOAP, Service HTTP rules can implement services in a way that is consistent with REST (Representational State Transfer).'
Not sure I fully understand what the above means but it seems to me like that it will allow you to create RESTful webservices but you will have to implement the REST architecture yourself. At least that what it looks like when I checked out a few OOTB HTTP services.
Ok, sounds good. I think we will have a full guide by the end of this forum topic. I hope I could use this topic as a sounding board of sorts.
Should I go down the: Designer Studio => Integration => Services => Service Wizard (Service Purpose: Invoke existing activity Rules & Service Type: HTTP) route or Create a new Service REST rule manually by selecting Service REST from the Integration-Services category in the Records explorer? What's the difference between the 2 approaches? And which one's easier?
Here's what I've figured so far.
As per the Pega 7 Platform Product Help for Service HTTP rules - https://community.pega.com/sites/default/files/help_v71/procomhelpmain.htm - 'A low-overhead stateless alternative to SOAP, Service HTTP rules can implement services in a way that is consistent with REST (Representational State Transfer).'
Not sure I fully understand what the above means but it seems to me like that it will allow you to create RESTful webservices but you will have to implement the REST architecture yourself. At least that what it looks like when I checked out a few OOTB HTTP services.
On the contrary, looking at some OOTB REST services, I can see the typical HTTP methods like GET, POST, PUT, DELETE sections in there along with some additional and useful features like query parameters mapping, etc.
Pegasystems Inc.
US
Hi,
Using a Wizard in Pega 7.1 does not preclude the ability to manually edit the Rules generated by the Wizard. These options are not mutually exclusive. Wizards help to "Jump Start" our development efforts and they save us a great deal of time. Try using the Wizard to get started and then feel free and comfortable editing and modifying the Rules generated by the Wizard to suite your specific requirements.
Regards,
Henry
Pega Academy
Adqura
GB
Hi,
There is wizard for creating HTTP services but not for REST and I am not yet sure on how to make the HTTP service created by the Service Wizard, conform to the RESTful architecture.
Regards,
Suraj
Pegasystems Inc.
US
Hi,
I am sorry, I stand corrected, I was confusing the "Create REST Integration" Connector Wizard with your request. I am escalating your question in the hopes someone else on our team may be able to provide a more lucid response.
Regards,
Henry
Pega Academy
Cisco
IN
Hi Suraj,
I have been working on creating rest services with json output. It seems Pega doesnt have a wizard for creating restful services. So what I did was create a service package manually, and then create a rest service using that package.
The challenge will be in parsing the json response, which will require use of Public APIs for xml to json conversion.
Dragon BPM Limited
GB
I have also been working on creating REST service through PRPC 7.1 and I am struggling with mapping the JSON message data. I manage to put the JSON string in a single string property on the clipboard by filling the "Message Data" section with "Map To" set to "Clipboard" and "Map To Key" to the clipboard property. However there is a "JSON" option for the "Map To" property but I am failing to make that work.
-
Jeffrey Silver
Dragon BPM Limited
GB
I have actually figured it out. If you have a JSON request, you can put "JSON" in the "Map To" and the name of a clipboard property in the "Map to key". That property needs to be a property of type "Page" with a data class that has properties with similar names than the payloads one. For example:
if JSON request is:
{
"company_identifier": "01234567",
"company_name": "Foo industries",
}
then Pega class and properties should be something like:
- ABC-FW-APP-Int-RESTSERVICE_Request
.company_identifier of type text
.company_name of type text
- ABC-FW-APP-Int-RESTSERVICE_Response
.createdCaseID of type text
- ABC-FW-APP-Int-RESTSERVICE
.Request of type Page with class: ABC-FW-APP-Int-RESTSERVICE_Request
I have actually figured it out. If you have a JSON request, you can put "JSON" in the "Map To" and the name of a clipboard property in the "Map to key". That property needs to be a property of type "Page" with a data class that has properties with similar names than the payloads one. For example:
if JSON request is:
{
"company_identifier": "01234567",
"company_name": "Foo industries",
}
then Pega class and properties should be something like:
- ABC-FW-APP-Int-RESTSERVICE_Request
.company_identifier of type text
.company_name of type text
- ABC-FW-APP-Int-RESTSERVICE_Response
.createdCaseID of type text
- ABC-FW-APP-Int-RESTSERVICE
.Request of type Page with class: ABC-FW-APP-Int-RESTSERVICE_Request
.Response of type Page with class: ABC-FW-APP-Int-RESTSERVICE_Response
then in your REST service rule:
- Service tab:
Page Class: ABC-FW-APP-Int-RESTSERVICE
- Method tab (then open the one you want to use, I have used POST as I want to create a work object):
Message Data on the Request sub tab:
Map To: JSON
Map To Key: .Request
Message Data on the Response sub tab:
Map From: JSON
Map From Key: .Response
Hope that helps!
COGNIZANT TECHNOLOGIES SERVICES PVT LTD
IN
Hi,
Could you please share the steps used for validating the working of the Service REST built by you.
Cisco
IN
Hi Damien,
Sorry for a delayed response!
The way I accomplished it was slightly different.
When I get a request,
Map To: Clipboard
Map To Key: Param.InParameter
I gathered all the data I wanted in a suitable Page. This page will be a step page for the Java step.Then I put the following code in Java:
PublicAPI tools = (PegaAPI) ThreadContainer.get().getPublicAPI();
ClipboardPage stepPage = tools.getStepPage();
String returnValue = stepPage.getJSON(false);
ResultJson = returnValue;
The result json is parsed into an out parameter(ABC). In the:
Map To: Clipboard
Map To Key: Param.ABC
Have you adopted the same approach for converting the result set to be returned to json, or have you tried some other approach?
Dragon BPM Limited
GB
The response I send has to be in JSON as well so I have done the same thing but reverse. Created a .Response property on the service class that is of type Page with a class that contains my response properties. Then in my service rule I have set "Map From" to "JSON" and "Map From Key" to ".Response". I'll update my example post to reflect that. Any reason why you proceeded the way you did instead of using "Map to" set to "JSON"?
Cisco
IN
I was not sure how exactly JSON mapping works for REST Services. Also, when I initially tried this process, I was not getting the response in json. I will try the method suggested by you again to see if it works. Will keep this post updated.
Mozido
US
Hello HarshalA,
What is the version of Pega you are using? Did your approach work for you?
Ai4Process
GB
Hi,
I was trying to do a POC using REST service. The request in the query string is having a param set like : "Hub.XYZ:xyz". For this we are getting an Inbound data mapping exception. But if we change the request param as "Hub_XYZ" then the inbound data is getting mapped properly.
The client is expected to send query using "." format. Can any one help in resolving this issue ASAP??
Thanks in advance.
Ankita