Defining the body of an HTTP request, response, and error response is optional. When you do not explicitly define the body element, the request or response returns the default payload.
The following example shows the XML configuration of an http:request operation that defines a custom body, a key/value query-parameter, an X-Custom header, and a uri-params with the uriParamsMap variable that populates the URI parameter uriParam:
<http:request path="/{uriParam}/test" config-ref="reqConfig">
<http:body>
#['Custom body']
</http:body>
<http:headers>
#[{'X-Custom' : 'custom'}]
</http:headers>
<http:uri-params>
#[uriParamsMap]
</http:uri-params>
<http:query-params>
#[{'key’' : 'value’'}]
</http:query-params>
</http:request>
The following example shows the XML configuration of an http:listener source that lacks a defined body element. The returned value is the default payload. The payload defines an http:response to a successful execution that consists of a 200 statusCode and Ok as the reasonPhrase, with headers Name as content, and Something as someValue:
<http:listener path="test" allowedMethods="GET" config-ref="lisConfig">
<http:response statusCode="200" reasonPhrase="Ok">
<http:headers>
#[{"Name" : "content", "Something" : someValue}]
</http:headers>
</http:response>
</http:listener>
The following example shows the XML configuration of an http:listener source that defines a response to an execution failure that returns a 502 statusCode and Failure as the reasonPhrase, with headers Error as FIRE and body as Oops, something is wrong:
<http:listener path="test" allowedMethods="GET" config-ref="lisConfig">
<http:error-response statusCode="502" reasonPhrase="Failure">
<http:body>
#[‘Oops, something is wrong’]
</http:body>
<http:headers>
#[{"Error" : "FIRE"}]
</http:headers>
</http:error-response>
</http:listener>