Configuring the Sample Policies

Contents

Overview

This topic introduces and explains how to setup the example policies available in the samples directory of your Enterprise Gateway installation. These include the following:

  • Conversion: exposes a SOAP service over REST.
  • Security:
    • verifies the digital signature on the request and creates a signature on the response.
    • decrypts the request and encrypts part of the response.
  • Throttling: limits the number of calls for a service.
  • Virtualized Service: combines threat protection, content-based routing (target a server according to request contents), and message transformation.

Important Note:
If you are new to the Enterprise Gateway, you should first read the following topics to get familiar with the main concepts and basic steps:

This guide assumes that you have already installed and started the Enterprise Gateway and Policy Studio. The Service Explorer client GUI testing tool is optional.

Enabling the Sample Services Interface

The HTTP interface for the sample policy services is disabled by default. To enable this interface, perform the following steps:

  1. In the Policy Studio navigation tree, select Listeners -> Oracle Enterprise Gateway -> Sample Services -> *:${env.PORT_SAMPLE_SERVICES}.
  2. Right-click, and select Edit to display the Configure HTTP Interface dialog.

    Configure HTTP Interface

    Configure HTTP Interface

  3. Select the Enable interface setting.
  4. Click OK.

Alternatively, you can also enable this HTTP interface using the web-based Traffic Monitor tool running on http://HOST:8090/trafficmonitor/, where HOST is the machine on which the Enterprise Gateway is running. Click the Settings button at the top right, and select the HTTP interface node under Sample Services.

Configuring a Different Sample Services Interface

All sample policy services are defined in an HTTP Services group named Sample Services. This group uses an HTTP interface running on the port specified in the ${env.PORT_SAMPLE_SERVICES} environment variable. This external environment variable is set to 8081 by default. If you wish to use a different port, you must configure this variable in the GW_INSTALL/conf/envSettings.props file. For example, you could add the following entry:

env.PORT.SAMPLE.SERVICES=8082 

For more details on setting external environment variables, see the topic on Deploying the Enterprise Gateway in Multiple Environments.

StockQuote Demo Service

All sample policies use a demo service named StockQuote, which is implemented using a set of policies. This service exposes two operations:

  • getPrice: the policy for this operation uses a sample script to randomly calculate a quote value. Each call to getPrice() returns a different value.
  • update: returns an Accepted HTTP code (202).

The StockQuote service is exposed on the following relative paths:

  • /stockquote/instance1
  • /stockquote/instance2

These relative paths are used in the Virtualized Service sample for content-based routing.

Sample Service URL
A Connect to URL filter with the following URL is used to invoke the StockQuote service from each of the sample policies:

 http://stockquote.com/stockquote/instance1 

The first part of this URL uses a Remote Host definition of stockquote.com. Remote Hosts are logical names that are used to decouple the hostname used in a URL from the server (or group of servers) that handles the request.

Remote Host Settings

In the Policy Studio, the Remote Host configuration is displayed under the process name (Oracle Enterprise Gateway) in the navigation tree, and is named stockquote.com:80. To view its settings, right-click, and select Edit to view the Remote Host Settings dialog:

Remote Host Settings

Remote Host Settings

On the General tab, the Remote Host is set to:

  • Use HTTP 1.1.
  • Use port 80 by default.
  • Include the ContentLength header in the request to the back-end server.
  • In case of an SSL connection, verify the Distinguished Name (DN) in the certificate presented by the server against the server’s hostname.

Remote Host Address Settings
On the Addresses tab, the Remote Host is set to send requests to localhost:${env.PORT_SAMPLE_SERVICES}, which resolves to localhost:8081 by default. You could also specify several servers in the Addresses list, and the Enterprise Gateway would load balance the requests across servers in the same group using the specified algorithm.

Remote Host Address Settings

Remote Host Address Settings

For more details on these settings, see Remote Host Settings.