Managing RESTful Web Services Metadata

Topics:

When the server accesses a RESTful Web Services provider, it needs to know how to pass parameters and accept responses for each REST request. In most RESTful Web Services, the Web Services provider documentation is used in determining the parameters to pass and the expected response. Therefore, the Create Synonym process sends a REST request including parameters to determine the response from the Web Service. A WADL (Web Application Description Language) file, which is in XML format, is sometimes used to define the request and response for each REST request.

Creating Synonyms

How to:

Reference:

A synonym defines a unique logical name (also known as an alias) for each Web Services operation. Synonyms are useful because:

  • They insulate client applications from changes to the location and identity of a request. You can move or rename a request without modifying the client applications that use it. You need make only one change, redefining the request synonym on the server.
  • They provide support for the extended metadata features of the server, such as virtual fields and security mechanisms.

Creating a synonym generates a Master File and an Access File. These are metadata files that describe the Web Services request to the server.

Each synonym you create represents a single operation.

Note: Each synonym describes the Web Services operations of a particular provider. If the operation parameters are changed, the synonym must be recreated.

Procedure: How to Create a Synonym

  1. From the Web Console sidebar, click Applications or Connect to Data.

    The Applications page opens.

  2. If you started from the Applications page, right-click an application folder, point to New, and click Synonym on the context menu.

    The Connect to Data page opens.

  3. On the Configured list, click the down arrow next to a connection for the configured adapter, or right-click a connection.

    Depending on the type of adapter you chose, one of the following options appears on the context menu.

    • Show DBMS objects. This opens the page for selecting synonym objects and properties.
    • Create metadata objects. This opens the page for selecting synonym objects and properties.
    • Show files. This opens a file picker. After you choose a file of the correct type, the page for selecting synonym objects and properties opens.
    • Show local files. This opens a file picker. After you choose a file of the correct type, the page for selecting synonym objects and properties opens.
  4. Enter values for the parameters required by the adapter as described in the chapter for your adapter.
  5. After entering the parameter values, click the highlighted button on the ribbon.

    The button may be labeled Next, Create Synonym, Create Base Synonyms, Create Cluster Synonym, or Update Base Synonyms.

    The synonym creation process for most adapters has been consolidated so that you can enter all necessary parameters on one page. However, for some adapters such as LDAP, you must click Next buttons until you get to a page that has a Create Synonym button.

The synonym is created and added under the specified application directory.

Note: When creating a synonym, if you choose the Validate check box (where available), the server adjusts special characters and checks for reserved words. For more information, see Validation for Special Characters and Reserved Words.

Reference: Synonym Creation Parameters for RESTful Web Services

The following list describes the parameters for which you will need to supply values, and related tasks you will need to complete in order to create a synonym for the adapter. These options may appear on multiple panes. To advance from pane to pane, click the buttons provided, ending with the Create Synonym button, which generates the synonym based on your entries.

Select REST Operation

Select one of the following REST operations:

  • Get. GET operation.
  • Insert. POST operation.
  • Update. PUT operation.
  • Delete. DELETE operation.
Service URL Extension

Is an extension to the Base URL used to perform specific functionality from the RESTful Web Service.

The Base URL is concatenated with the Service URL Extension at run time to make the REST request. This parameter must have a value. For example:

postalCodeSearch
Service URL Parameters

Are the parameter name and value pairs that will be used in making a REST request in order to create metadata from the response.

The input parameter names will also be included in the metadata.

It is important to note that with certain RESTful Web Services, different parameters and/or parameter values could return a different structured response. Therefore, different synonyms should be created for each differently structured response. For example:

postalcode=9011&maxRows=10&username=demo
Provide document sample

This parameter becomes visible only if Insert or Update is selected as the operation.

It is used in conjunction with the Service URL Parameters field by passing the Body portion of the REST request to create the metadata. The body can be made up of any combination of name-value pairs, XML, and JSON. For example:

IBIRS_action=put&object=<object _jt="IBFSUserObject" description="Rest Userid" email="restid@informationbuilders.com" password="rest"  
type="User"> <status _jt="IBSSUserStatus" name="ACTIVE"/> </object>&IBIRS_replace=true 
Validate

Select the Validate check box if you wish to convert all special characters to underscores and perform a name check to prevent the use of reserved names. (This is accomplished by adding numbers to the names.) This parameter ensures that names adhere to specifications. See Validation for Special Characters and Reserved Words for more information.

When the Validate option is unchecked, only the following characters are converted to underscores: '-'; ' '; ' \'; '/'; ','; '$'. No checking is performed for names.

Make unique

Select the Make unique check box if you wish to set the scope for field and group names to the entire synonym. This ensures that no duplicate names are used, even in different segments of the synonym. When this option is unchecked, the scope is the segment.

Synonym Name

Enter a name to assign to the synonym.

Application

Select an application directory. The default value is baseapp.

Prefix/Suffix

If you have tables with identical table names, assign a prefix or a suffix to distinguish them. For example, if you have identically named human resources and payroll tables, assign the prefix HR to distinguish the synonyms for the human resources tables. Note that the resulting synonym name cannot exceed 64 characters.

If all tables and views have unique names, leave the prefix and suffix fields blank.

Overwrite Existing Synonyms

To specify that this synonym should overwrite any earlier synonym with the same fully qualified name, select the Overwrite existing synonyms check box.

Note: The connected user must have operating system write privileges in order to recreate a synonym.

Reference: Managing Synonyms

Once you have created a synonym, you can right-click the synonym name in the Adapter navigation pane of either the Web Console or the Data Management Console to access the available options.

For a list of options, see Synonym Management Options.

Reference: Master File Attributes

Attribute

Description

PROPERTY

Indicates whether the field corresponds to an XML attribute or an XML element.

REFERENCE

Identifies the parent element of the field in the XML hierarchy, as defined by the Web Services XML schema document.

The format is

segmentname.fieldname

where:

segmentname

Is the name of the Master File segment in which the field resides.

fieldname

Is the name of the field that corresponds to the parent element.

Reference: Access File Attributes

Attribute

Description

SEGNAME

Value must be identical to the SEGNAME value in the Master File.

CONNECTION

Indicates a previously declared connection. The syntax is:

CONNECTION=connection                      
OBJECT

Service URL Extension as defined during the Create Synonym process.

HEADER

The GROUP name in the Master File that defines the parameters for the REST request.

SERVICETYPE  

The Service Type which will always be REST.

HTTPMETHOD 

The HTTP method used in the REST request, for example, GET or POST.

RESTRESPONSE 

The type of response returned from the REST request. Valid values are XML or JSON.

HTTPBODY 

If HTTPMETHOD=POST, setting HTTPBODY=ENCODE will encode the body of the request.

Reference: Sample REST Synonym

The following synonym was generated using the following connection and synonym creation parameters:

Base URL
http//api.geonames.org

The base URL is entered on the Add Connection page.

The remaining entries are on the Create Synonym page.

Select REST Operation

Select Get.

Service URL Parameters

Enter the following parameters:

postalcode=10121&country=US&maxRows=10&username=demo
Synonym Name

Enter postalCodeSearch.

In addition, check the Validate and Make Unique check boxes, then click Create Synonym.

postalCodeSearch Master File

FILENAME=M6ILO, SUFFIX=REST    , $
  SEGMENT=M6ILO, SEGTYPE=S0, $
   GROUP=HEADER, ALIAS=Header, ELEMENTS=4, $
    FIELDNAME=POSTALCODE, ALIAS=postalcode, USAGE=A30, ACTUAL=A30, ACCESS_PROPERTY=(NEED_VALUE),
      XDEFAULT='10121', $
    FIELDNAME=COUNTRY, ALIAS=country, USAGE=A30, ACTUAL=A30, ACCESS_PROPERTY=(NEED_VALUE),
      XDEFAULT='US', $
    FIELDNAME=MAXROWS, ALIAS=maxRows, USAGE=A30, ACTUAL=A30, ACCESS_PROPERTY=(NEED_VALUE),
      XDEFAULT='10', $
    FIELDNAME=USERNAME, ALIAS=username, USAGE=A30, ACTUAL=A30, ACCESS_PROPERTY=(NEED_VALUE),
      XDEFAULT='demo', $
    FIELDNAME=__RESPONSE, USAGE=TX80L, ACTUAL=TX, ACCESS_PROPERTY=(INTERNAL), $
  SEGMENT=RESPONSE, SEGTYPE=S0, SEGSUF=XML     , PARENT=M6ILO, POSITION=__RESPONSE, $
    FIELDNAME=GEONAMES, ALIAS=geonames, USAGE=A1, ACTUAL=A1, ACCESS_PROPERTY=(INTERNAL),
      PROPERTY=ELEMENT,  $
    FIELDNAME=TOTALRESULTSCOUNT, ALIAS=totalResultsCount, USAGE=P33, ACTUAL=A33,
      REFERENCE=GEONAMES, PROPERTY=ELEMENT,  $
    FIELDNAME=CODE, ALIAS=code, USAGE=A1, ACTUAL=A1, ACCESS_PROPERTY=(INTERNAL),
      REFERENCE=GEONAMES, PROPERTY=ELEMENT,  $
    FIELDNAME=POSTALCODE1, ALIAS=postalcode, USAGE=P33, ACTUAL=A33,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=NAME, ALIAS=name, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=COUNTRYCODE, ALIAS=countryCode, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=LAT, ALIAS=lat, USAGE=P20.3, ACTUAL=A20,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=LNG, ALIAS=lng, USAGE=P20.3, ACTUAL=A20,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=ADMINCODE1, ALIAS=adminCode1, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=ADMINNAME1, ALIAS=adminName1, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=ADMINCODE2, ALIAS=adminCode2, USAGE=P33, ACTUAL=A33,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=ADMINNAME2, ALIAS=adminName2, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=ADMINCODE3, ALIAS=adminCode3, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $
    FIELDNAME=ADMINNAME3, ALIAS=adminName3, USAGE=A55, ACTUAL=A55,
      REFERENCE=CODE, PROPERTY=ELEMENT,  $

postalCodeSearch Access File

SEGNAME=M6ILO, 
  CONNECTION=geonames, 
  OBJECT=postalCodeSearch, 
  HEADER=HEADER, 
  SERVICETYPE=REST, 
  HTTPMETHOD=GET, 
  RESTRESPONSE=XML, $

WebFOCUS

Feedback