Creating Multiple Response based REST Service/Reference
A multiple response based REST Service is a service whose operations are configured to respond with various media types. To specify these response media types, the content keyword is used at the status code level.
In any Swagger file, to define multiple responses a similar structure is seen as below:
In the above example, GET operation when responding with 200 status code can provide a reply with application/json, application/xml or text/plain content-type based on the Accept header sent in the request.
In a similar way if an operation is responding with Fault status codes, then it can also be configured with multiple media types.
In TIBCO BusinessWorks Container Edition, you can create multiple response based REST Service/Reference using an OAS 3.0 swagger file.
For more information to create a top-down REST Service, see Using Swagger to Create a REST Service
For more information to create REST Reference from a Swagger file, see Using Swagger to Create a REST Reference
In TIBCO BusinessWorks Container Edition, the following UI changes are seen specific to multiple response service.
1. | REST Service and Reference Binding |
a. | In the Service Binding section, the Response tab for the operation displays only the following check boxes : Use HTTP Headers Use Custom Status Line Respone with Status Code Only (By default, this field is disabled) Use Empty Values for Null |
b. | In the Reference Binding section, the Response tab for the operation displays only the following check boxes: Use HTTP Headers Use Null for Empty values Ignore Additional JSON Fields. The descriptions for these fields can be found in the corresponding REST Service and Reference Binding sections. |
2. | Response Status tab![]() For multiple response based service, the Response Status tab shows all the status codes (including success and error codes), in the same tab. This tab shows the following details: |
a. | Status Code - This field shows the HTTP status codes defined in the Swagger file for the particular operation. |
b. | Media Type - This field displays the content-types defined for the particular operation. The content-types which we already support, like JSON, XML, Text and Binary media types would work. |
c. | Type - Data type of the status code, for example XSD Element, String, Integer or Boolean. |
d. | Reason Phrase - Description of the status code defined in the Swagger file. |
3. | Reply activity on REST Service: On the General section, select the following available options from the Reply With field to send the reply message:
Input Tab Similar behavior is seen when the service is replying with fault. |
4. | Invoking Multiple response based service: To invoke a multiple response based service we have to provide the Accept Header value in the Input tab of the Invoke activity, based on the expected response content-type. For example, if we want the response in image/jpeg format, then we can pass the same in the Accept Header. |