Search Results

REST Service Binding

REST Binding provides external connectivity for REST over HTTP. You can specify custom HTTP headers and parameters using REST binding. It supports POST, GET, PUT, PATCH, and DELETE HTTP methods. It also supports JSON, XML, and plain text message types.

Binding

This section has the following fields.

Field Description
Resource The name of the resource.
Resource Service Path Specify the path of the Service Resource.

If an application contains multiple REST bindings, ensure that the location of the path parameters is unique for each REST binding.

For example, one REST binding is using the paths /book/{isbn} and another REST binding is using the path /book/{authorid}. Since {isbn} and {authorid} are defined at the same location in the URI , one of these services will not function correctly.

HTTP Connector Name The name of the HTTP Connector.
Tip: Click on the HTTP Connector Name field to display details about the HTTP Connector resource.
Response Client Format The type of response message format.

The two available response message format options are: JSON and XML.

Enforce BW Service Response Select the check box to set the response preference to BW Service Response.

By default, the check box is not selected, and the response preference is set to the Accept Header response. See, "Accept Header Responses" in the REST Reference guide, for details on REST Service responses based on the Accept Header settings.

Operations

This section shows the following details.

Field Description
Name The name of the HTTP method used, for example, POST, GET, PUT, PATCH, or DELETE.
Nickname The specified name of the service, for example, getBooks.

Operation Details

This section shows the following details.

Field Description
Summary This tab has the following available options:
  • Summary: The summary of the REST resource
  • HTTP Method: Displays the HTTP Method specified in the Operations section. These are the available HTTP methods:
    • POST
    • GET
    • PUT
    • DELETE
    • PATCH
Request

Specifies the resource created, using the POST, PUT, or PATCH methods. Body, form, query, and header parameters are supported.

Note: Request and Response depend on the method selected.
Response This tab has the following available options:
  • Use HTTP Headers: Selecting this check box includes the REST Web service application (or client) within the HTTP headers and body of a request, all of the parameters, context, and data required by the server-side component to generate a response.
  • Use Custom Status Line: You can specify a custom status line (status code and reason phrase) to the outgoing message. The codes used must be defined in the configuration under the Response Status tab.
  • Response with Status Code Only: The operation returns a status code as response, when this check box is selected. Message body is not required. For example, using a POST operation returns a 201 status code which means "Created" and responds with the resource URL.
  • Resource Schema: Displays the schema selected. This option is not available when the Use Custom Status Line and Response with Status Code Only check boxes are selected. These are the available options:
    • String
    • Integer
    • Boolean
    • XSD element: Selecting this option to either select the XSD schema element available under the Schemas folder of your project or a create new XML schema resource. Click Create New Schema to a create new XML schema resource using the Simplified Schema Editor wizard.
Response Status Specifies the response code for the operation and the code message. For example, code 201 means Created or code 503 means Service Unavailable.

You can also add your own custom code and reason phrase.

Parameters

This section shows the following details.

Parameter Name Type Required
Parameter name of the operation used The parameter type. It can be any one of the following:
  • String
  • Integer
  • Boolean
Whether this parameter is required. The available options are Yes or No.

About Swagger UI

Using the Swagger UI you can visualize RESTful services. It specifies the format (URL, method, and representation) to describe REST the web services.

Viewing Multiple REST Services in Swagger UI

If there are multiple REST services using different HTTP Connectors, you can the select the required HTTP Connector to receive responses for all the REST services using that connector. From the Swagger UI, select the connector from the options in the drop down list Select HTTP Connector.

At runtime, in the Swagger UI, the REST service lists down all the REST services that are using the selected HTTP Connector.

Partial Response in REST

Using the Partial Response feature in REST, you can retrieve only the data you need, instead of bulk data as a response. You can also request only those fields that are required as part of the response.

For example, in the Swagger UI to select the immediate children nodes of an object, specify the required field names separated by comma such as ISBN, author, bookName, and so on.

The partial response feature uses a fields query parameter.

Note: The fields keyword is reserved to be used internally. Adding the fields keyword as a query parameter automatically triggers support for partial responses.

Partial responses do not support selecting particular objects from an array. For example, using the fields keyword for /books/isbn, the isbn's of all the books are returned.

Format: The values of the fields keyword can be a comma separated value of fields of the response message. Fields can be specified directly, for example, using isbn or hierarchy /books/isbn. To use this in the resource path in the client, add the fields keyword, for example /books?fields=isbn, and to use this on the service binding pass the fields as a query parameter in the resource service path, for example /books?{fields} .

OSGi Command to List REST

The OSGi command to list REST and Swagger URLs is lrestdoc, which lists the following discovery URL:

<>@BWEclipseAppNode> lrestdoc

[Application Name]: tibco.bw.sample.binding.rest.BookStore.application

[Discovery Url]

The following are the commands to list endpoints.

<>@BWEclipseAppNode> lendpoints

[Application Name] : tibco.bw.sample.binding.rest.BookStore.application

[Endpoint Type] : REST

[Endpoint URL] : http://localhost:8123

[CLIENT FORMAT ] : JSON

[RESOURCE PATH ] : /book/{ISBN}

[HTTP METHODS] : GET, PUT, DELETE

[Endpoint Type] : REST

[Endpoint URL] : http://localhost:8123

[CLIENT FORMAT ] : JSON

[RESOURCE PATH ] : /books

[HTTP METHODS] : POST, GET

[Endpoint Type] : REST

[Endpoint URL] : http://localhost:8123

[CLIENT FORMAT ] : JSON

[RESOURCE PATH ] : /book/{ISBN}/events

[HTTP METHODS] : GET

[Endpoint Type] : REST

[Endpoint URL] : http://localhost:8123

[CLIENT FORMAT ] : JSON

[RESOURCE PATH ] : /event/{EventID}

[HTTP METHODS] : GET, PUT, DELETE

[Endpoint Type] : REST

[Endpoint URL] : http://localhost:8123

[CLIENT FORMAT ] : JSON

[RESOURCE PATH ] : /events

[HTTP METHODS] : POST, GET

Policy

Bindings that support policies will display the Policy field. To associate a new or existing policy with the REST binding, click the Add Policy icon. To edit policy details, click Policy Name. The Policy section has the following fields.

Field Description
Policy Name The name of the policy.
Policy Type The type of policy associated with the binding. The REST Service Binding can support the Basic Authentication policy.
Description A description of the policy.