Contents
This topic introduces and explains how to set up the example policies available in the
samples
directory of your API 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.
Tip | |
---|---|
If you are new to the API Gateway, you should first read the following to get familiar with the main concepts and basic steps:
|
This guide assumes that you have already installed and started the API Gateway and Policy Studio. The API Gateway Explorer client GUI testing tool is optional.
The HTTP interface for the sample policy services is disabled by default. To enable this interface in the Policy Studio, perform the following steps:
-
In the navigation tree, select Listeners > API Gateway > Sample Services > *:${env.PORT_SAMPLE_SERVICES}.
-
Right-click, and select Edit to display the Configure HTTP Interface dialog.
-
Select the Enable interface setting.
-
Click OK.
Alternatively, you can also enable this HTTP interface using the web-based API Gateway Manager
tool running on http://HOST:8090
, where HOST
is the machine on
which the Node Manager is running.
-
Click the Settings button in the API Gateway Manager toolbar.
-
Select the HTTP interface node under Sample Services on the left.
-
Select the Interface Enabled setting on the right.
-
Click the Apply button.
Note | |
---|---|
Settings made in the web-based API Gateway Manager tool are dynamic settings only, which are not persisted. |
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 INSTALL_DIR/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 for API Gateway instances, see the API Gateway Deployment and Promotion Guide.
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 decouple the
hostname in a URL from the server (or group of servers) that handles the request.
In the Policy Studio, the Remote Host configuration is displayed under the API Gateway
instance name (API 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:
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 and Load Balancing 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 to use instead of DNS lookuplist, and the API Gateway would
load balance the requests across servers in the same group using the specified algorithm.
For more details on these settings, see Configure remote host settings.