Consumption of external rest services
We need to consume external rest services . External team provided us with following steps to consume their endpoint url. Is it feasible in pega to consume the url in below provided format.
1.Add secure-request-rest-template (Jar) as a dependency if your application is servlet based
<dependency>
<groupId>com.xxxxx.enterprise</groupId>
<artifactId>secure-request-rest-template</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
2. Follow the below guidelines in your classes which are responsible for calling protected APIs
• Call the provider protected endpoint using standard RestTemplate, eg:
@GetMapping(value = "/private", produces = MediaType.TEXT_PLAIN_VALUE)
@ResponseBody
public String callProviderHelloEndpoint() {
log.info("Calling private endpoint on provider");
ResponseEntity<String> response = restTemplate.exchange("https://com.xxxx.enterprise/example-provider/hello", HttpMethod.GET, null, String.class);
return response.getBody();
}
The URL must follow this convention - [http | https]://<namespace>/<service-name>/<URI>] where namespace and service-name are of the provider service.
We need to consume external rest services . External team provided us with following steps to consume their endpoint url. Is it feasible in pega to consume the url in below provided format.
1.Add secure-request-rest-template (Jar) as a dependency if your application is servlet based
<dependency>
<groupId>com.xxxxx.enterprise</groupId>
<artifactId>secure-request-rest-template</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
2. Follow the below guidelines in your classes which are responsible for calling protected APIs
• Call the provider protected endpoint using standard RestTemplate, eg:
@GetMapping(value = "/private", produces = MediaType.TEXT_PLAIN_VALUE)
@ResponseBody
public String callProviderHelloEndpoint() {
log.info("Calling private endpoint on provider");
ResponseEntity<String> response = restTemplate.exchange("https://com.xxxx.enterprise/example-provider/hello", HttpMethod.GET, null, String.class);
return response.getBody();
}
The URL must follow this convention - [http | https]://<namespace>/<service-name>/<URI>] where namespace and service-name are of the provider service.
Conversion Examples
URL example for the examples below → http://com.xxx.y.z/a-b-c
Application configuration → com.xxx.y.z.a-b-c
To convert, use the URL used in the Rest Template (https://name.space/service-name), remove "http://", replace the '/' with a '.'
Environment variables → COM_XXX_Y_Z_ABC
To convert, use the URL used in the Rest Template (https://name.space/service-name), remove "http://", update all text to upper case, replace the '/' with a '_', remove all '-', and replace all '.' with '_'
The environment variable transformation needs to upper case, replace the '/' with a '_', remove all '-', and replace all '.' with '_'
The application variable transformation needs to replace the '/' with a '.'
Using either will work in secure request.
Also, in the URL resolution code, the application config is checked before environment variables.