For HTTP calls to e.g. REST services, a Pega 7 HTTP proxy may have to be configured. This is the case when the Pega 7 Exercise System from Pega Academy –using VMWare Player or Oracle VM VirtualBox– is installed on a machine within a network that requires a network proxy for Internet connections.
- Here, the Pega 7 Exercise System is installed as per Installing Pega 7 on Mac OS with Oracle VirtualBox.
The screen shot below shows the Pega 7 Designer Studio home page. On page load, 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.
- 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 a Pega 7 HTTP proxy.
Summary
- The Pega 7 pyInvokeRESTConnector Activity for REST Service Calls
- Option A: Set System Properties for Pega 7 HTTP Proxy in Tomcat
- Option B: Set System Properties for Pega 7 HTTP Proxy in Java Activity Step
Related Posts
- Install Pega 7 Exercise System on Tomcat 9 and PostgreSQL
- Call REST Service in Pega 7 with Connect REST Rule
- Call SOAP Service in Pega 7 with Connect SOAP Rule
1 The Pega 7 pyInvokeRESTConnector Activity for REST Service Calls
- The PDN News feed section relies on a data page called
D_PDNFeed
, which uses a Connect REST rule calledpyRSSConnectService
as its data source.
- 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.
- 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 addresshttp.proxyPort
– the HTTP proxy port, ususally 80 or 8080http.proxyUser
– the username (optional)http.proxyPassword
– the password (optional)2 Option A: Set System Properties for Pega 7 HTTP Proxy in Tomcat
- 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 addresshttp.proxyPort
– the HTTP proxy port, ususally 80 or 8080http.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):
- 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.
3 Option B: Set System Properties for Pega 7 HTTP Proxy in Java Activity Step
- 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.
- When the activity is executed, the REST call succeeds and the service page contains the GET response data:
2 thoughts on “Configure Pega 7 HTTP Proxy for REST Service Calls”