How to connect to a JSON REST service in PEGA 6.1 SP2?
To adhere to firmwide policies, our interface partner is converting an existing soap service to a JSON based REST service. The only possible way to connect to a REST service in PEGA 6.1 is through Connect-Http rule. I found one relevant post but i did not get a clear picture on what this requirement entails. Could anyone please list out all the necessary steps needed to achieve this requirement? Our application is divest and hence we are not planning for a PEGA upgrade.
You will have to write your own JSON parser and streamer, perhaps by leveraging a third-party library such as Jackson. You could create two RUFs - to convert JSON to Clipboard and vice-versa. You will have to configure your HTTP connector such that the response is mapped to a single-value property which your RUF takes as input along with the target ClipboardPage you need to map the response to. Likewise, the streamer RUF takes ClipboardPage as input and outputs a string containing the JSON. This string can be copied to the parameter page or a temp property and referenced in the HTTP connector request tab.
I see that the ObjectMapper class of the Jackson API provides methods to convert a Java object to JSON object and vice versa. But, how do we convert a Clipboard page into a Java Object or JSON string. I tried to search engine API in 6.1 but i do not seem to find one that does the conversion. Any clues on this?
You will have to iterate through the Clipboard page properties and construct the JSON string manually based on the property type. The following methods might help:
ClipboardPage.values() - returns a collection of properties on this page
Iterate through the collection returned above, each item is of type ClipboardProperty.
Use ClipboardProperty.getMode() to identify if it is a single-value property or a complex property (page/page list/page group, etc.) and ClipboardProperty.getType() to identify if it is a string/number/boolean and construct JSON string accordingly.