Virtualizing a Service

Overview

This topic explains how to virtualize an example service using the web-based API Service Manager tool available in API Gateway Manager. It uses a simple Google Search REST API service. This topic assumes you have already performed all the steps described in Starting the API Gateway Tools.

Accessing the Example Service

The example Google Search REST API service is based on Asynchronous JavaScript and XML (AJAX). This service supports an HTTP GET method, and returns a JSON-encoded response with an embedded status code. The following URL shows an example Google Search method call:

http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Einstein

The following example shows an extract from a corresponding JSON-encoded response:

{
  "responseData": {
      "results": [
          {
             "GsearchResultClass": "GwebSearch",
             "unescapedUrl": "http://en.wikipedia.org/wiki/Albert_Einstein",
             "url": "http://en.wikipedia.org/wiki/Albert_Einstein",
             "visibleUrl": "en.wikipedia.org",
             "cacheUrl": "http://www.google.com/search?q=cache:dx1QfR_DgCUJ:
               en.wikipedia.org",
             "title": "Albert <b>Einstein</b> - Wikipedia, the free encyclopedia",
             "titleNoFormatting": "Albert Einstein - Wikipedia, the free encyclopedia",
             "content": "Albert <b>Einstein</b> was a German theoretical physicist 
             who developed the theory of  general relativity, effecting a revolution 
             in physics ...
          },
          ....
          {
             "GsearchResultClass": "GwebSearch",
             "unescapedUrl": "http://www.einstein.edu/",
             "url": "http://www.einstein.edu/", "visibleUrl": "www.einstein.edu",
             "cacheUrl": "http://www.google.com/search?q=cache:np0jSqbXd7EJ:
              www.einstein.edu",
             "title": "<b>Einstein</b> Healthcare Network | Hospitals in Philadelphia, 
              PA Area", "titleNoFormatting": "Einstein Healthcare Network | Hospitals 
              in Philadelphia, PA Area", "content": "Philadelphia's largest independent 
              Academic Medical Center with 7 hospitals in the Philadelphia & Montgomery 
              Area."
          }
       ...
      }
  },
  "responseDetails": null,
  "responseStatus": 200
}

[Important] Important

The Google Search API service is provided for illustration only, and is not intended for production use. For more details, see https://developers.google.com/web-search/terms

Creating a Workspace in API Service Manager

You must first create a workspace in API Service Manager as follows:

  1. Click the API Service Manager button in the API Gateway Manager toolbar.

  2. Select the group and API Gateway instance that you wish to use to virtualize the service (for example, the Group1 and APIServer1).

  3. Click the Create button to create the workspace.

  4. Enter the configuration passphrase (if one exists for this API Gateway instance), and click OK.

  5. Click the Virtualize API Service button on the left in the toolbar of the API Services tab to launch the New API Service wizard.

Step 1—Basic Information

The first step in the New API Service wizard is to specify the service URL. Perform the following steps:

  1. Click No, my Service will be defined manually, and enter GoogleSearch in the Name field.

  2. Enter the following URL in the Destination URL field:

    http://ajax.googleapis.com/ajax/services/search/web?v=1.0

    Alternatively, if you wish to virtualize service with a WSDL file, click Yes, I know a URL from which to get a WSDL, and enter a WSDL URL for the service. For more details, see Managing API Services.

  3. Click Next to specify how the service is exposed.

Step 2—Service Exposure

The second step in the wizard enables you to specify how the service is exposed. For example, this includes details such as the protocol (HTTP), services group (Default Services), and relative path (/ajax/services/search/web). For example, you may wish to virtualize a service on a different relative path. You can also click Show Details to view the default port address.

Click Next to use the default values for the example service.

Step 3—Request Processing

The third step in the wizard enables you to specify policy packages used for request processing (for example, an OAuth policy package for authentication). Click Next to use no request processing for the example service.

For more details on policy packages, see Configuring Policy Packages

Step 4—Routing

The fourth step in the wizard enables you to specify policy packages used for routing (for example, a JMS policy package). Click Next to use the Default URL-based Routing policy package for the example service.

Step 5—Response Processing

The fifth step in the wizard enables you to specify policy packages used for response processing (for example, a policy package that removes sensitive information such as credit card details from the message). Click Next no response processing for the example service.

Step 6—Monitoring

The sixth step in the wizard enables you to specify the monitoring options for the service. For example, these include monitoring the service usage, usage per client, and client usage. By default, the authentication.subject.id message attribute is used to identify the client. Click Next to use the default values for the example service.

Step 7—Tags

The final step in the wizard enables you to specify tags for this service. Tags are user-friendly names to help organize, search, and browse API Gateways and services in API Gateway Manager and Policy Studio. Perform the following steps:

  1. Click the green plus icon to add a tag.

  2. Enter a Tag name (for example, Dept).

  3. Enter a Value (for example, QA).

  4. Click Finish.

The virtualized service is displayed on the API Services tab. For more details, see Managing API Services.

Registered Service

Deploying to a Group

When you have completed the steps in the wizard, you must deploy the updated configuration to a API Gateway group, or a subset of API Gateways in a group. Perform the following steps:

  1. Click Actions -> Deploy on the left in the API Services tab.

  2. In the Deployment Wizard, select the group and API Gateway instance(s) to which you wish to deploy the current working configuration, and click the Next.

  3. Enter a comment for this deployment (for example, registering google search service).

  4. Click Deploy.

  5. Click Finish.

[Note] Note

Services virtualizeed using API Service Manager and deployed to the API Gateway can also be viewed in the Policy Studio tree under the Business Services -> API Service Manager node. For details on using Policy Studio to import services, see Web Service Repository.

Accessing the Virtualized Service

When you virtualize a service, and deploy it to the API Gateway, the API Gateway protects the service. This means that instead of connecting to the service directly, clients connect through the API Gateway. The API Gateway can then apply policies to messages sent to the destination service (for example, to enable security, routing, monitoring, or acceleration).

When the virtualized service is deployed to the API Gateway, the published URL now uses the host and port of the API Gateway. In the case of the example service, you can test the new URL on which the service is available to clients in your browser. Using the default service exposure settings, the virtualized example service is availalbe on the following URL path:

http://HOST:8080/ajax/services/search/web

where HOST is the machine on which the API Gateway is running.

Monitoring a Service

When you have virtualized the example Service, the next step is to monitor the service using the API Gateway Manager monitoring tools. For details, see Monitoring Services.