Invoke REST Web Service Policy Example

This example illustrates a simple sequence with a single task. The task executes the Invoke REST Web Service policy, which sends a GET request to Google Maps for the geographical coordinates of a specific address. Because this example does not require a request string, it does not specify a request data object. The response is stored in output data object named Response, which is a text type object.
Note: This example invokes an external web service that might require proxy server configuration for your web application server.
The following figure shows the workflow tree and workflow diagram for this example. The workflow has task-level data objects for the response and error values.
The workflow tree shows a workflow named Invoke REST Service that has task-level data objects named error code, error message, and response. The workflow has one task named Invoke Service with a policy named “Task Started –> Invoke REST Web Service”.
The data objects in the Invoke REST Web Service task have the following properties:
Data Object Label
Type
Value
Response
Long Text Object
None (It is populated by the web service. If the expected response could exceed 4000, then use the Long Text data type.)
Error Code
Number
None (It is populated if an error occurs.)
Error Message
Short Text
None (It is populated if an error occurs.)
The policy definition associated with the task is as follows:
Policy Property
Value
Name
Task Started->Invoke REST Web Service
Event
Task Started
Action
Invoke REST Web Service
Description
This policy is used to invoke an unregistered web service function over REST.
Web Service Location
http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=500%20SAS%20Campus%20Drive%2C%20Cary%2C%20NC
HTTP Method
GET
Content Type
None (The default is text/plain.)
Web Service Input
None
Web Service Output
None
Error Code
Invoke REST Web Service/Invoke Service/Error Code
Error Message
Invoke REST Web Service/Invoke Service/Error Message
User Name
None
Password
None
Note: The JSON syntax endpoint is specified, so the response is a JSON string.
The final response stored in the Response output data object is as follows:
{
   "results": [   {
      "address_components":       [
                  {
            "long_name": "500",
            "short_name": "500",
            "types": ["street_number"]
         },
                  {
            "long_name": "Sas Campus Drive",
            "short_name": "Sas Campus Dr",
            "types": ["route"]
         },
                  {
            "long_name": "Cary",
            "short_name": "Cary",
            "types":             [
               "locality",
               "political"
            ]
         },
                  {
            "long_name": "Cary",
            "short_name": "Cary",
            "types":             [
               "administrative_area_level_3",
               "political"
            ]
         },
                  {
            "long_name": "Wake",
            "short_name": "Wake",
            "types":             [
               "administrative_area_level_2",
               "political"
            ]
         },
                  {
            "long_name": "North Carolina",
            "short_name": "NC",
            "types":             [
               "administrative_area_level_1",
               "political"
            ]
         },
                  {
            "long_name": "United States",
            "short_name": "US",
            "types":             [
               "country",
               "political"
            ]
         },
                  {
            "long_name": "27513",
            "short_name": "27513",
            "types": ["postal_code"]
         }
      ],
      "formatted_address": "500 Sas Campus Drive, Cary, NC 27513, USA",
      "geometry":       {
         "location":          {
            "lat": 35.823976,
            "lng": -78.7579669
         },
         "location_type": "ROOFTOP",
         "viewport":          {
            "northeast":             {
               "lat": 35.8253249802915,
               "lng": -78.7566179197085
            },
            "southwest":             {
               "lat": 35.8226270197085,
               "lng": -78.75931588029151
            }
         }
      },
      "types": ["street_address"]
   }],
   "status": "OK"
}
Last updated: March 5, 2020