HTTP 要求、応答、およびエラー応答の本文は、必要に応じて定義します。本文要素を明示的に定義しない場合、要求または応答はデフォルトのペイロードを返します。
次の例は、カスタム body、キー/値 query-parameter、X-Custom header、URI パラメーター uriParam を入力する uriParamsMap 変数を含む uri-params を定義する、http:request 操作の XML 設定を示しています。
<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>
次の例は、定義された body 要素が欠けている http:listener ソースの XML 設定を示しています。返される値は、デフォルトのペイロードです。このペイロードには実行に成功した場合の http:response が定義されており、statusCode として 200、reasonPhrase として Ok、headers の 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>
次の例は、実行に失敗した場合の応答を定義する http:listener ソースの XML 設定を示しています。statusCode として 502、reasonPhrase として Failure、headers の Error に FIRE、body に 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>