The HTTP Headers sent to Stambia Web Services at invocation can be retrieved and used seamlessly in the Processes.
Stambia also offers the possibility to define as many output HTTP Headers as needed, that will be returned at the end of the Web Service's invocation.
Prerequisites:
- This is only available for the HTTP REST API
- Stambia DI Runtime S17.3.0 or higher
Retrieving Input HTTP Headers
Creation of the Process Parameters
First, create the Process Parameters that will receive the values of the HTTP Headers sent at invocation.
Design them as usual, and set a default value to avoid the case where it wouldn't be provided by the user.
Configuration of the META-INF
Next, lead to the main Process Properties, and open the Meta-Inf tab.
Add in the box the following sample of code and replace it with your own settings:
<httpRestWebServiceProperties extractRequestInfo="true"> <requestHeaderMapper headerName="HeaderName" parameterName="My_HTTPHeader_Parameter_01" /> </httpRestWebServiceProperties>
Attribute | Description | Example |
headerName | The name of the HTTP Header sent at invocation | Content-Type |
parameterName | The name of the Process Parameter in which the retrieved value should be loaded. | My_HTTPHeader_Parameter_01 |
You can put as many <requestHeaderMapper /> node as needed:
<httpRestWebServiceProperties extractRequestInfo="true"> <requestHeaderMapper headerName="HeaderName" parameterName="My_HTTPHeader_Parameter_01" /> <requestHeaderMapper headerName="HeaderName02" parameterName="My_HTTPHeader_Parameter_02" /> <requestHeaderMapper headerName="HeaderName03" parameterName="My_HTTPHeader_Parameter_03" /> </httpRestWebServiceProperties>
Using the parameters in the Process
That's it, from now at each invocation the Process Parameters will be filled with the HTTP Headers provided by the user calling the Web Service.
You can then use the Process Parameters as usual in your flow.
Publishing Output HTTP Headers
Creation of the Process Parameters
First, create the Process Parameters that will contain the values of the HTTP Headers.
Design them as usual, and set a default value to avoid the case where it wouldn't be filled during the Process.
Configuration of the META-INF
Next, lead to the main Process Properties, and open the Meta-Inf tab.
Add in the box the following sample of code and replace it with your own settings:
<httpRestWebServiceProperties extractRequestInfo="true"> <responseHeaderMapper headerName="HeaderName" parameterName="My_Output_HTTPHeader_Parameter_01" /> </httpRestWebServiceProperties>
Attribute | Description | Example |
headerName | The name of the HTTP Header that will be returned. | Content-Type |
parameterName | The name of the Process Parameter that will contain the HTTP Header value. | My_Output_HTTPHeader_Parameter_01 |
You can put as many <responseHeaderMapper /> node as needed:
<httpRestWebServiceProperties extractRequestInfo="true"> <responseHeaderMapper headerName="HeaderName" parameterName="My_Output_HTTPHeader_Parameter_01" /> <responseHeaderMapper headerName="HeaderName02" parameterName="My_Output_HTTPHeader_Parameter_02" /> <responseHeaderMapper headerName="HeaderName03" parameterName="My_Output_HTTPHeader_Parameter_03" /> </httpRestWebServiceProperties>
Usage
At the end of the Web Service invocation, all the response HTTP Headers specified will be sent back to the user.
The values sent are the values of their corresponding Process Parameters, which should be filled during the Process execution.
Alternative for default value
It is also possible to set a default value directly in the <responseHeaderMapper /> if you do not need to have a configurable value :
<httpRestWebServiceProperties extractRequestInfo="true">
<responseHeaderMapper headerName="HeaderNameWithDefaultValue" defaultValue="default value"/>
</httpRestWebServiceProperties>
Remarks
If you are mixing Input / Output headers, make sur to put all the nodes under the same <httpRestWebServiceProperties /> root node.
For instance:
<httpRestWebServiceProperties extractRequestInfo="true"> <requestHeaderMapper headerName="HeaderName" parameterName="My_HTTPHeader_Parameter_01" /> <requestHeaderMapper headerName="HeaderName02" parameterName="My_HTTPHeader_Parameter_02" /> <requestHeaderMapper headerName="HeaderName03" parameterName="My_HTTPHeader_Parameter_03" /> <responseHeaderMapper headerName="HeaderName" parameterName="My_Output_HTTPHeader_Parameter_01" /> <responseHeaderMapper headerName="HeaderName02" parameterName="My_Output_HTTPHeader_Parameter_02" /> <responseHeaderMapper headerName="HeaderName03" parameterName="My_Output_HTTPHeader_Parameter_03" /> </httpRestWebServiceProperties>