Configure Pega 7 to use HTTP Proxy for REST Services

For calls to REST services, Pega 7 may have to be configured to use a HTTP proxy. This is the case when Pega 7 is run from within a network that requires Internet connections via a network proxy.

The screen shot below shows the Pega 7 Designer Studio home page. On page load, the Pega 7 will attempt to connect via a REST service to the PDN to get the news. When Pega 7 is running behind a network proxy, this call fails and the error Unable to connect to the PDN at this time. is shown.

Pega 7.1.9 - Home Page - Unable to Connect to the PDN at this Time.

  • The Pega logs show a java.net.UnknownHostException because the target host is unknown:
2017-09-20 18:08:56,601 [http-nio-8080-exec-7] [  STANDARD] [          ] [    MyStore:01.01.01] 
(nvoke.Rule_Connect_REST.Action) ERROR  [email protected] 
- com.pega.pegarules.pub.services.ConnectorException: 
Caught unhandled exception: java.net.UnknownHostException: pdn.pega.com: unknown error
  • This post shows 2 options for configuring Pega 7 to use a HTTP proxy for REST service calls.

Summary

  1. The Pega 7 pyInvokeRESTConnector Activity for REST Service Calls
  2. Option A: Set System Properties for Pega 7 HTTP Proxy in Tomcat
  3. Option B: Set System Properties for Pega 7 HTTP Proxy in Java Activity Step

Related Posts

  • The PDN News feed section relies on a data page called D_PDNFeed, which uses a Connect REST rule called pyRSSConnectService as its data source.

Pega7.1.9 Home Page - PDN News Feed Data Page D_PDNFeed

  • For Connect REST rule executions, Pega 7 uses the activity pyInvokeRESTConnector to facilitate the HTTP GET or POST call. This activity contains Java steps that use the Apache HttpPClient API.
  • In step 4 of the activity, there is logic to check for HTTP proxy system properties.

Pega 7 activity pyInvokeRESTConnector - Java step for HTTP proxy credentials

  • In order for this activity to use a HTTP proxy, these system properties need to be set:
http.proxyHost – the HTTP proxy hostname or IP address
http.proxyPort – the HTTP proxy port, ususally 80 or 8080
http.proxyUser – the username (optional)
http.proxyPassword – the password (optional)

  • System properties can be added to Tomcat using the catalina.properties file.
  • This file is located in the <tomcat-root>/conf folder.
  • On the Pega 7.1.9 Exercise System, running on a virtual machine, the file is located at:
/opt/tomcat/conf
  • On the Pega 7.1.6 Exercise System, running on a virtual machine, the file is located at:
/usr/share/tomcat7
  • Open the catalina.properties file and add the following system properties:
http.proxyHost – the HTTP proxy hostname or IP address
http.proxyPort – the HTTP proxy port, ususally 80 or 8080
http.proxyUser – the username (optional)
http.proxyPassword – the password (optional)
  • The catalina.properties file should look like this example (here, username and password are set too):

Tomcat - catalina.properties - Set System Properties

  • Note that the backslash character in the username is encoded using \u0005c as per the Unicode standard. For details on this see Java properties backslash discussion on stackoverflow.
  • Restart Tomcat or if you are running the Pega 7 Exercise System, restart the virtual machine.
  • The PDN news feed on the Designer Studio home page should now load successfully as shown below.

Pega 7.1.9 - Home Page - PDN News Feed.

  • If an activity is used to call the Connect REST rule, a Java step in the activity can be used to set the system properties before the call to the REST service.
System.setProperty("http.proxyHost", "proxy.abc.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyUser", "users\\ssmith");
System.setProperty("http.proxyPassword", "password12345");
  • In the below example, the same Connect REST rule is executed in a custom activity using the Connect-REST method. A Java step is used to set the HTTP proxy system properties.

Activity Definition Tab - LoadPDNNewsFeed

  • When the activity is executed, the REST call succeeds and the service page contains the GET response data:

Show-Page - REST Service GET Response - PDN News Feed

One thought on “Configure Pega 7 to use HTTP Proxy for REST Services

  1. How can I have a list of all REST-Connectors used by an application regardless of what layer they are created. They could be created in enterprise layer or FW layer or implementation layer. I need to regenerate a list of all REST connectors that are directly or indirectly referred/used by an application.

Leave a Reply