Version: 17.07
Supported Since: 17.07
HTTP Response Code Setter processing element can be used to set a HTTP response code to a message and optionally a reason phrase associated with that response code.
In order to use this processing element, you must first select the HTTP NIO Connector dependency from the connector list when you are creating an empty Ultra project. If you have already created a project, you can add the HTTP NIO Connector dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list, select the HTTP NIO Connector dependency. |
Next |
The processing element will add the specified response code (and the reason phrase if provided) to the message context and it will be forwarded to this outport |
On Exception |
The message context will be sent to this outport if any exception occurred while setting the response code |
Response Code * |
Basic |
The HTTP response code to be set to the message. This should be a non-negative integer value. |
Reason Phrase |
Basic |
An optional reason phrase to be associated with the response code. If this is not specified, system will attempt to determined a reason phrase based on the current locale. If it also failed, the reason phrase will be empty. |
In the following use case, the basic requirement is to receive HTTP requests from external clients and proxy them to
a backend server, which expects each request to contain a header named client-id
. So the integration flow
should check the existence of this header, and if it is present, those requests should be directly proxied to the
backend server. If the header is missing, those requests should not be sent to the backend server, but a response
with the response code 400
and reason phrase No client-id header
should be sent to the client.
In this flow, a HTTP Ingress Connector is used to receive requests from clients and next a Condition Evaluator
processing element is configured as below to check the existence of the header with name client-id
.
The If-Then outport of the Condition Evaluator (which will receive the message if the header is present) is connected to a HTTP Egress Connector that is configured to forward the request to the backend server. The Response processor outport of that egress connector is connected to the Response port of the ingress connector, so that the response from the backend server will be directly sent out as the response to the original request.
The Else outport of the Condition Evaluator (which will receive the message if the header is missing) is
connected to a HTTP Response Code Setter processing element, which is configured as below to set the response code
400
and the reason phrase No client-id header
and forward the message to the Response port of the ingress
connector.