HTTP 要求、応答、およびエラー応答の本文は、必要に応じて定義します。本文要素を明示的に定義しない場合、要求または応答はデフォルトのペイロードを返します。
次の例の要求では、Custom body (カスタム本文)、キー=値クエリパラメーター、値が custom の X-Custom ヘッダーが定義されます。uriParamsMap 変数によって URI パラメーター 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>
次のコードには、明示的に定義された本文要素がありません。返される値は、デフォルトのペイロードです。このペイロードには成功した実行の応答が定義されており、状況コード 200、理由を示す語句 Ok、ヘッダーとして Name とその値 content および Something とその値 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>
次のコードには失敗した実行の応答が定義されており、状況コード 502、理由を示す語句 Failure、ヘッダーとして Error とその値 FIRE、本文として Oops, something went terribly wrong が含まれます。
<http:listener path="test" allowedMethods="GET" config-ref="lisConfig">
<http:error-response statusCode="502" reasonPhrase="Failure">
<http:body>
#[‘Oops, something went terribly wrong.’]
</http:body>
<http:headers>
#[{"Error" : "FIRE"}]
</http:headers>
</http:error-response>
</http:listener>