Managing REST Resource Definitions
This section discusses how to:
Configure a REST resource definition.
Define a REST base URL.
Define a document template.
Define a URI template.
Use the URI Template Builder.
Validate a URI template.
Use the URI Template Builder to build a URI template.
When you configure a REST resource definition the end result is the URL that the service consumer uses to invoke the service.
The information defined in the REST resource definition is included in the WADL document that the service provider furnishes to the service consumer. The service consumer then extracts the information from the WADL document and defines it in the consumer service operation it creates for the service.
REST service operation definitions contain a REST Resource Definition section where you configure and manage the resource definition.
The REST resource definition is where you define the REST base URL, one or more URI templates, and a document template. The section also contains a feature that enables you to validate the defined URI templates.
To build URI templates you can manually enter template strings or use the URI Template Builder.
This section describes REST resource definition concepts.
REST Base URL
The REST base URL is the common part of the URL to invoke the provider or consumer web service.
For a REST service provider this value is always the REST target location entry defined on the Service Configuration page for provider service operations. When the Provide Web Service wizard is used to create the WADL document, the option to select a secure REST target location can be selected. For provider service operations this URL is simply informational to show what would be used when creating the complete URL(s).
The REST base URL is constructed as part of the initialization/retrieval of the service operation and uses the following format:
<Provider REST target location>/< External alias from any-to-local routing>/
For a REST consumer the common part of the URL defined is the provider's WADL document.
Document Template
A document template is a Document type message that define in the REST resource definition. The document message has primitive elements and collection elements defined with names used for value replacement within the URI template. This document can only contain primitive elements and collection elements. The document cannot contain any imports (compounds) or compound elements. The advantage of using documents is that they cannot be inadvertently changed, as is not the case with defined records and/or fields.
Note: In the Document definition, the variables defined with the braces ( {} ) in the URI template must be the exact name of the element name defined on the Document page, not the Tag Name defined on the XML page.
A document template is a URI on the wire with values in it.
URI Template
Resources are constructed using URI templates. URI templates use a simple syntax where braces denote variables to be replaced when the templates are converted to actual URLs. You define the values for the URI template variables in the REST document template.
You can define one or more URI template strings to define one or more resources for the definition
Note: PeopleSoft supports direct variable substitution.
The following example shows a sample URI template syntax:
weather/{state}/{city}?forecast={day}
The denoted variables identified with the braces ( {} ) are replaced with the actual values as defined in the document template. In the example shown the variables are state, city and day.
The system validates the string entered for the template to ensure that there is no equivalent or ambiguous defined templates currently entered on the grid. Moreover the values used within the braces ( {} ) must be defined on the document template to pass validation.
You can build URI templates by manually entering variable strings in the template fields in the REST Resource Definition or you can use the URI Builder. Each of these methods for building URI templates is discussed later in this topic.
URI Index
The system assigns an integer index value to each URI template you create for a REST service operation upon save.
You will later use these index numbers in PeopleCode to call and manipulate the associate URI template.
URI Template Validation
When you construct a URI template, you can verify the URL produced.
The REST Resource Definition URI grid features a Validate link that provides access to the Validate URI page where you can populate the URI with values from the document template and then test the link.
When building URI templates it is necessary to know these terms:
Field or Control |
Definition |
---|---|
Expression |
The text between ‘{‘and ‘}’, including the enclosing braces. |
Expansion |
The string result obtained from a template expression after processing it according to its expression type, list of variables names, and value modifiers. |
PeopleSoft supports the URI template expressions shown in the table. The table summarizes each type of template expression by its associated operator. The example expansions are based on the following variables and values:
var := “value”
tools := “tools rules!”
empty := “”
list := [ “val1”, “val2”, “val3” ]
path := “/foo/bar”
x := 1024
y := 768
In each code example, the values in the first column are the expressions and the values in the second column are the expansions.
Expression Type |
Operator |
Description |
---|---|---|
Form-Style (Continuation.) |
|
Form-style query continuation
|
Form-Style (Expansion.) |
|
Form-style query expansion.
Note that the expansion process omits the equal sign ( = ) when the variable value is empty. |
Fragment. |
|
Fragment expansion with comma-separated values.
|
Label. |
|
Label expansion, dot-prefixed
|
Path-Segment. |
|
Path-segments, slash-separated
|
Path-Style. |
|
Path-style parameters, semicolon-prefixed.
Note that the expansion process omits the equal sign ( = ) when the variable value is empty. |
Reserved. |
|
Reserved expansion with comma-separated values.
|
Simple String. |
NA |
Simple expansion with comma-separated values.
|
Note the following about the operators, expressions, and expansions shown in the table:
The operator’s associated delimiter (“;”, “?”,”/”,”.”,”#”) is omitted when none of the listed variables are defined.
Multiple variables and list values have their values joined with a comma (“,”) if there is no predefined joining mechanism for the operator.
The operators plus ( + ) and fragment ( # ) substitute non-encoded reserved characters found inside the variables value; the other operators pct-encode reserved characters found in the variable values prior to expansion.
The explode modifier (“*”) indicates that the variable represents a composite value that may be substituted in full or partial forms, depending on the variables type or schema. The asterisk (“*”) indicates that just the component names and values are included in the expansion.
The REST target URL must be specified on the Service Configuration – Target Locations page. The steps for defining the REST target location are described elsewhere in the product documentation.
See Understanding Configuring PeopleSoft Integration Broker for Handling Services.
You must have created a Document type message that contains the values for any variable data you plan to use in the URI templates. For this reason you must have an understanding of PeopleSoft Documents Technology to create and manipulate Document type messages.
For information on PeopleSoft Documents Technology see the product documentation for Documents Technology.
This section lists the steps to configure a REST resource definition. Other section within this topic provide in-depth information and procedures to complete each step.
To configure a REST resource definition:
Access the Service Operations – General page (select
).Locate the REST Resource Definition section of the page.
In the REST Base URL field, enter the base URL.
In the Document Template field, enter the name of the document message to associate to the resource definition or click the Lookup button to search the database.
In the Template field, enter the syntax for the URI template.
There are two options to create and enter the URI template syntax:
Manually create and enter the syntax.
Use the URI Template Builder page to create and enter the syntax.
Click the Save button.
(Optional.) Click the Validate link to validate a URI template.
This section describes defining REST base URLs for provider and consumer service operations.
Understanding Defining REST Base URLs
For provider service operations the system auto-populates the REST base URL. As mentioned elsewhere in the product documentation, the base URL is composed of the REST target namespace defined on the Service Configuration page and the routing alias defined on the Routings – Parameters page on the any-to-local routing for the service operation. The REST base URL takes the following format:
http://<ProviderRESTTargetNamespace>/<RoutingAlias>
For example:
http://providerserver.example.com:8010/PSIGW/RESTListeningConnector/weatherstation.v1
For consumer service operations you obtain the REST base URL from the WADL document furnished to you by the service provider. You specify the URL in the REST Base URL field in the REST Resource Definition section of the Service Operations – General page.
Specifying REST Base URLs (Provider Services)
As described previously, the REST base URL for a provider service operation is auto-populated by the system. The value populated comes from the REST target location defined on the system and the routing alias defined on the any-to-local routing definition for the service operation.
The REST base URL for a provider service operation appears in a read-only field in the REST Resource Definition section of the Service Operations – General page.
To access the Service Operations – General page select
The example shows that the system has populated the REST base URL as described earlier in this topic.
To modify the REST base URL for a provider service operation you must change the REST target namespace defined on the Service Configuration – Target Namespace page and/or the routing alias for the any-to-local routing as defined on the Routings – Parameters page.
See Setting Target Locations for REST ServicesConfiguring Routing Definitions
Specifying REST Base URLs (Consumer Services)
The service provider furnishes service consumers the value of the base URL to define, usually in a WADL document. As the service consumer you then define this value in the REST Resource Definition section of the Service Operations – General page in the consumer service operation definition.
To access the Service Operations – General page select
To specify the REST base URL for a consumer service, in the REST Base URL field enter the URL provided by the provider. The format is:
http://providerserver.example.com:8010/PSIGW/RESTListeningConnector/weatherstation.v1
To define a document template:
Access the REST Resource Definitions section of the Service Operations – General page (
In the Document Template field enter a document name or use the Lookup button to search for one.
After you select a message, you can click the View Message link to view it.
Click the Save button.
Use the REST Resource Definition section on the Service Operations – General page to build one or more URI template strings to define one or more resources for the definition.
To access the Service Operations – General page select
Use this section to add one or more template URI strings to define one or more resources for the service operation definition.
A URI template format example appears just about the URI grid for you to use as a guide for building URI templates.
In the example the URI
grid shows that there are four URI templates defined for the service
operation. The QE_WEATHERTEMPLATE.v1 value defined in the Document Template field is a Document type message. The message contains the primitive
elements to supply values for country, state, city and day indicated
by the variables {country}
, {state}
, {city}
, and {day}
defined in the URI templates.
You cannot save a URI template until you define a document template. The processes for defining document templates is described earlier in this topic. Note, too, that when you save the resource definition, the system assigns a sequential URI index to each URI template.
To manually build a URI template enter the URI string in the Template field in the REST Resource Definition section of the Service Operations – General page. The URI template expressions supported are described earlier in this topic.
To access the page select
This example shows two
URI template strings added to template, weather/{state}/{city}
and weather/{state}
. Note that neither of the added URI strings has an index value.
When the page is saved, the system assigns a sequential index values
to each URI string added.
To manually build a URI template:
Access the REST Resource Definition section on the Service Operations – General page.
To access the page select
In the URI grid, click the Add a Row button (+) to add a row for the template.
Manually enter the URI string.
Click the Save button.
Using the URI Template Builder page (IB_URIBUILDER_SEC) to build URI templates can simplify building complex or lengthy URIs.
This section describes how to access the URI Template Builder page and describes the fields and controls you use to build a URI template.
The steps to build a URI template using the URI Template Builder page vary, depending on the document template defined and the business requirements and goals of each URI template. An example that illustrates using the URI Template builder to build a URI template appears at the end of this topic.
Prerequisites for Using the URI Template Builder
To build a URI template using the URI Template Builder you must first define a document template in the resource definition. The document template must contain the values for the variables you plan to build out in the URI template.
Using the URI Template Builder
To access the URI Template Builder select Build link.
The Service Operations – General page appears. In the REST Resource Definition section of the page, click theThe URI Template Builder features three sections for building a URI template:
Field or Control |
Definition |
---|---|
Expression Workspace |
Use this section to build the expression. The system reads the document template defined for the resource definition and makes the primitive and collection variable elements defined in the document available to build the URI. After you build an expression click the Append to URIbutton to add it to the URI Template field at the bottom of the page. |
Constant |
Use this section to define constants and then append them to the URI Template field at the bottom of the page. |
Separator |
Use this button to append the value in the URI Template field with a forward slash (“/”). |
The following fields and controls appear on this page:
Field or Control |
Definition |
---|---|
Expression Type |
Select an expression type from the drop-down list. The values are:
The expression types are discussed in detail earlier in this topic. |
Primitive |
Select the control to build an expression based on a primitive element contained in the document template. After you select the control select a primitive element from the drop-down list. By default this control is enabled. |
Type |
This read only field displays the data type of the primitive element selected. |
Add |
Click the button to add the selected primitive or collection element to the expression field at the bottom of the Expression Workspace. |
Collection |
Select the control to build an expression based on a collection element contained in the document template. After you select the control select a collection element from the drop-down list. Click the Add button to add the element to the expression field. |
Explode Modifier |
This control becomes enabled after you add a collection element to the expression field. Select an explode modifier from the drop-down list and click the Explode Modifier box to add it to the collection element in the expression field. Currently, the asterisk explode modifier (“ * “) is the only explode modifier supported. |
Append To URI |
Click the button to append the URI Template field with the expression, constant, or separator. |
Constant |
Enter a constant value to append to the URI. |
URI Template |
Displays the URI template string. |
Validate |
Click the button to access the Validate URI page to validate the URI template string. |
OK |
Click the button to populate the Template field in the resource definition with the value in the URI Template field and to return to the Service Operations – General page. |
Cancel |
Click the button to exit the URI Template Builder page without saving any information. |
This section discusses how to:
Use the Validate URI page.
Use the Set Value page.
Validate a URI template.
Using the Validate URI Page
After you construct a URI template you can verify the URL produced by using the Validate URI page (IB_SVCVERIFY_SEC). Use the Set Value page (IB_LSTESTER_SEC) to set test values for the URL.
To access the Validate URI page select Validate link next to the URI template for the URL to validate.
and click theThe Validate URI page displays the document information and the elements defined in the document template specified for the REST resource definition.
The name of the URI template that is selected for validation appears in the URI Template field. In the previous example, the following URI template appears in the URI Template field and is selected for validation:
weather/{state}/{city}?forecast={day}
To validate the URI template, you click each element in the document tree that corresponds to each variable in the URI template, and enter a test value for use in validation using the Set Value page.
Note: Using the Set Value page is described in the next section.
After you assign a test value for a template, the test value appears next to the element in the document tree.
After you enter test values click the Generate URL button to generate a URL to test.
The following fields and controls appear on the page:
Field or Control |
Definition |
---|---|
Package |
Package name in which the document is defined. |
Document |
Document name. |
Version |
Document version. |
Document Tree |
Displays the element defined in the document template. Click an element name to access the Set Value page and to set test values for the element. |
URI Template |
This field displays the URI template string created using the URI Template Builder page. |
Generate URL |
Click the button to generate a URL based on the test values entered. |
URL |
After you click the Generate URL button, this field displays the generated URL. |
Return |
Click the button to return to the URI Template Builder page. |
Using the Set Value Page
Use the Set Value page to enter test values for URI template validation.
When you click an element in the document tree on the Validate URI page, the Set Value page (IB_LSTESTER_SEC) appears.
The Set Value page provides information about the primitive element selected to assist you in providing a useful value to test. The information that appears varies, depending on the primitive type for which you are providing a value. After you set a test value for an element, the test value appears next to the element name on the document tree.
The Element Name field displays the element name with which you're working.
In the example, the Primitive Type field and Field Length field display the data type and length as defined for the element in the document.
The name of the field where you enter a test value depends on the data type. In the previous example, the data type is a string, and therefore the system prompts you to enter a Long value.
The following table lists the possible labels for the field where you enter a test value:
Data Type |
Primitive Type Field Label |
Test Value Field Label |
---|---|---|
Binary |
Bin |
Long |
Boolean |
Bool |
Page displays a check box. |
Character |
Character |
Char |
Date |
Date |
Date |
DateTime |
DT |
Datetime |
Decimal |
Dec |
Numeric |
Integer |
Int |
Numeric |
String |
String |
Long |
Text |
Text |
Long |
Time |
Time |
Time |
When you have defined test values for all variables in the URI template, click the Generate URL button to generate a URL based on the test values you entered.
Validate URI Templates
To validate a URI template:
Access the Validate URI page ( Validate link next to the URI template for the URL to validate.
and click theIn the document tree click an element to define a test value.
The Set Value page appears.
Enter a test value for the element and click the OK button.
The Validate URI page appears.
Repeat step 2 and step 3 for each variable element in the URI template.
On the Validate URI page, click the Generate URL button.
The URL generated based on the test values entered appears in the URL field.
Cut and paste the URL into a browser to test.
Click the Return button to return to the Service Operations – General page.
This section provides an example of using the URI Template Builder to build a URI template. This section discusses how to:
Access the URI Template Builder.
Build the expression string for the example URI template.
Append the expression string to the example URI template.
Add a separator to the example URI template.
Add a constant to the example URI template.
Validate the example URI template.
Add the example URI template to the REST resource definition.
Understanding the URI Template Builder Example
The documentation in this section describes how to use the URI Template Builder page to create a URI template for the provider service QE_WEATHERSTATION using the QE_WEATHERSTATION.V1 document template illustrated throughout this topic.
This example illustrates building the following URI template:
{state,country}/WhiteSalmon
In this example:
There is one simple string expression,
{state, country}
.This expression consists of two primitive elements.
There is one constant, WhiteSalmon.
The expression and constant are separated by a separator (“ / “).
Note: In this example, the prerequisites for building a URI template have already been met: the REST base URL is defined and the document template is defined.
Accessing the URI Template Builder
To start, access the REST resource definition for the service operation (
The Service Operations – General page appears).The service operation is currently defined with three URI templates. In this example a fourth URI template will be defined using the URI Template Builder page.
In the last row in the URI grid, click the Build link. The URI Template page appears.
Building the Expression String for the Example URI Template
This section describes
how to build the expression string {state,country}
.
To build an expression string, use the Expression Workspace section of the URI Template Builder page.
To build the expression string:
In the Expression Workspace, from the Expression Type drop-down list, select Simple String.
Click Primitive. and from the Primitive drop-down list, select state and click the Add button
The
{state}
expression appears in the expression field.From the Primitive drop-down list, select country. and click the Add button.
The country element is added to the
{state}
expression. And the value in the expression field is{state,country}
as shown in the previous example.Click the Append to URI button.
In the Separator section, click the Append to URI button.
A forward slash is added to the URI in the which now appears as
{state,country}/
In the Constant section, enter White Salmon and click the Append to URI button.
The constant is added to the URI and now appears as
{state,country}/WhiteSalmon
.Under the URI string, click the Append to URI button.
The string is added to the URI Template field and the template is complete.
Appending the Expression String to the Example URI Template
After you have created an expression you add it to the URL template.
To append an expression from the Expression Workspace to the URL Template field, click the Append to URI button at the bottom of the Expression Workspace.
Adding a Separator to the Example URI Template
To add a separator to a URI template, click the Append to URI button in the Separator section of the URI Template Builder page.
When you click the Append to URI button in this section, the system appends the value in the URI Template field with a forward slash (“/”).
Adding a Constant to the Example URI Template
The constant to add to the URI template for this example is WhiteSalmon.
To add a constant to a URI template use the Constant section of the URI Template Builder page.
When you click the Append to URI button in the Constant section, the value entered is appended to the URI template in the URI Template field.
To add a constant to a URI template:
Enter the constant value in the Constant field.
Click the Append to URI button.
Validating the Example URI Template
Click the Validate button on the URI Template Builder page to access the Validate URI page to validate and test the URI template. Use the page to define test values for the variable elements in the URI template.
The top of the page shows the document template metadata information. The tree structure shows the elements used in the document template. And the URI Template field shows the URI template to test.
In this example the
URI template to test is {state,country}/WhiteSalmon
. The variables in the template are those in the expression {state,country}
and WhiteSalmon
is a constant. Since only test values for variables are defined
for testing, test values will be set for the state and country elements.
In this example the following test values are set to test the URI template:
Document Template Element |
Test Value |
---|---|
state |
Washington |
country |
United States |
To define test values, click an element in the document tree structure to access the Set Value page.
After you set a value for an element, the value appears in the document tree view on the Set Value page.
After you defined test values for all variable elements in the URI template, click the Generate URL button to generate a URL to test.
The URL field in the previous example shows the URL generated. The complete URL is:
http://providerserver.example.com:8010/PSIGW/RESTListeningConnector/WeatherStation.v1/Washington,United%20States/WhiteSalmon
Cut and paste the URL into a browser for testing.
To validate the example URI template:
From the URI Template Builder page, click the Validate button.
The Validate URI page appears.
Define a test value for the state element.
Click the state element in the document tree.
The Set Value page appears.
In the Long field enter Washington.
Click the OK button.
The Validate URI page appears and the test value Washington appears after the state element in the document tree structure.
Define a test value for the country element.
Click the country element in the document tree.
The Set Value page appears.
In the Long field enter United States
Click the OK button.
The Validate URI page appears and the test value United States appears after the country element in the document tree structure.
Click the Generate URL button
The generated URL appears in the URL field.
Copy the URL to test in a browser.
Click the Return button to return to the URL Template Builder page.
After you have created the URI template and performed any necessary validation, add it to the REST resource definition.
The URI template appears in the REST Resource Definition section of the Service Operations – General page.
The URI template created in this example appears in the last row of the URI grid. Note that you must save the service operation definition to save the URI template. When you save the service operation definition the system assigns an index to the URI template.
In the example shown, the service operation has been saved as indicated by an index number appearing next to the example URI template.
To add a URI template to the REST resource definition:
After you complete the URI template and perform any validation, on the URI Template Builder page click the OK button.
The Service Operations – General page appears. The URI template appears in REST Resource Definition section of the page in the URI grid.
Click the Save button.
The URI template is saved and the system assigns an index to the URI template.