Publishing a REST Service
This section describes how to add a REST-compliant data service. The configuration steps are optional.
• | Configuration Options for Publishing a REST Service |
• | Publishing a REST Data Service |
Configuration Options for Publishing a REST Service
This setting determines whether to enclose an XML output parameter with a wrapper element in a TDV REST Web Service when the parameter is a generic XML type.
To configure XML output parameter wrapper elements
1. | From the Administration menu, choose Configuration. |
2. | Search for or navigate to the Generic XML REST Output Parameter Wrapper parameter. |
3. | Set the value to False to exclude the wrapper element, or set the value to True to include the wrapper element. |
4. | Stop and restart the TDV server to ensure that the parameter value change is recognized. |
5. | Make sure that the procedure that you define has a variable of data type ‘XML’. |
For Example
Assume that the Output parameter for the following code snippet is cust_data and that the data type is a generic XML type.
<ns1: cust_addr>
<mail_addr>
. . .
</mail_addr>
</ns1:cust_addr>
Set the Generic XML REST Output Parameter Wrapper parameter to true, to obtain output similar to:
<cust_data>
<ns1: cust_addr>
<mail_addr>
. . .
</mail_addr>
</ns1:cust_addr>
</cust_data>
If you do not want the parameter name wrapper in your output, set the configuration parameter to false. For example:
<ns1: cust_addr>
<mail_addr>
. . .
</mail_addr>
</ns1:cust_addr>
Publishing a REST Data Service
To publish a REST data service
-
Select the Web Services node under the Data Services node in the Studio resource tree.
-
Right-click and select New Composite Web Service.
-
For Data Service Name, enter a name for your Web service.
-
Click OK.
-
From the resource tree, open the data service that you just created.
By default, the SOAP tab is displayed.
-
Optionally, publish views and procedures to the Web service:
Select one or more tables, view, or procedure from the resource tree, and right-click.
Select Publish.
In the Publish window, type the name to use for the published resource.
Select the Web service to which you want the resource to be published.
Click OK.
-
In the Service portion of the screen, type or select values for the following properties.
If the property has a default value, a value is required.
-
From the upper part of the Operations section, select a Web service view or procedure that is available for use.
If you publish a new view or procedure to the Web service while this window is open, you might need to close and reopen this window for it to appear in the list.
-
In the lower part of the Operations section, type or select values for the properties listed in the following table.
Property |
Description |
|||||||
HTTP Method |
Select the verb associated with the procedure, for example GET, POST, PUT, or DELETE. Depending on the choices you have made for the operations field, these options might already be defined. |
|||||||
Operation URL Path |
Specify the operation URL path as defined for your operation. Follow endpoint URL guidelines to configure your values. You can use brace tags. You can specify a portion of the endpoint URL to be used in each Web service module. In a published WSDL file, the URL defining the target endpoint address is found in the location attribute of the port's soap:address element. |
|||||||
Input Message |
||||||||
|
Parameter Style |
Use this field to determine the shape of the input argument or message. This value applies to all parameters.
|
||||||
|
Wrapper |
|
||||||
|
Element Name |
Unique name for the wrapper element. For example, if you type wrappedOrderParams here, the WSDL XML includes an element: <wrappedOrderParams> </wrappedOrderParams> |
||||||
|
Element Type |
This is the type value of your row element. |
||||||
Output Message |
||||||||
|
Parameter Style |
The value applies to all parameters.
|
||||||
|
Wrapper |
|
||||||
|
Element Name |
Unique name to give to the wrapper element. For example, if you type wrappedOrderParams here, the WSDL XML includes an element: <wrappedOrderParams> </wrappedOrderParams> |
||||||
|
Element Type |
This is the type value of your row element. |
||||||
Endpoint URLs |
||||||||
|
HTTP/JSON |
Displays the HTTP/JSON endpoint URL for this operation. |
||||||
|
HTTPS/JSON |
Displays the HTTPS/JSON endpoint URL for this operation. Present only if Enable SSL is true in the Service section of this panel. |
||||||
|
HTTP/XML |
Displays the HTTP/XML endpoint URL for this operation. |
||||||
|
HTTPS/XML |
Displays the HTTPS/XML endpoint URL for this operation. Present only if Enable SSL is true in the Service section of this panel. |
-
Save your settings.
-
Repeat the steps in Publishing a SOAP Data Service for each operation or view you want to define for the Web service.
-
If your operation has parameters, go to the Parameters portion of the screen and select a parameter from the upper list.
-
In the lower part, type or select values for the following properties for input or output parameters.
Property |
Resource Type |
Description |
||||||
Name |
All |
Name of the parameter. Cannot be edited. |
||||||
Row Element Name |
Table |
Fully qualified name to give to the input parameter, output parameter, or output cursor; or name (relative to the cursor path) to give to the column. |
||||||
Row Type Name |
Table |
(Cursor only) Type value of this row element. |
||||||
Cursor Type Name |
Table |
(Cursor only) Unique name for the type that defines the global cursor element. |
||||||
Element Name |
All |
Can be NULL. The default value of the Element Name field specifies the schema of the REST message that is encrypted. This procedure can be used to encrypt the REST message body. |
||||||
Binding Location |
Procedure |
When the selected operation is a procedure, you can define binding locations. If the message is BARE, exactly one parameter must use the BODY binding location. The available locations for input are: ENTITY (not available for GET), QUERY, HEADER The available locations for output are: ENTITY |
||||||
Query |
Procedure |
The parameter-name part of a query string. The query argument can accept NULL values. For example, the following query arguments are both valid:
|
||||||
Default Value |
Procedure |
Optional. Default value to use for the parameter if a parameter value is not passed through the request. |
||||||
Nullable |
Procedure |
Whether this field is allowed to have no value. True specifies that the parameter can be passed to the server with no value. Without a value for the parameter, all data is returned from the query. |
||||||
Element Name |
Procedure |
Can be NULL. The default value of the Element Name field specifies the schema of the REST message that is encrypted. This procedure can be used to encrypt the REST message body. |
||||||
Direction |
All |
Indicates the direction of the input parameter, output parameter, or output cursor. Cannot be edited. |
-
Repeat the steps for each parameter to be defined for the Web service.
-
Save your definition.
Accessing the Published REST Services
Using this tool, the users can get the response schema and verify that it is as expected.
Note: The users can only see the published REST services that they have READ privileges for.