Methods

Methods

Complete reference for all HTTP methods supported by the pfx-rest component, the full URI parameter list, and usage examples.


HTTP Methods

GET

Standard HTTP GET for retrieving resources.

XML
<route id="restGet">
    <from uri="direct:fetchData"/>
    <to uri="pfx-rest:get?connection=myRestConn&amp;uri=/api/v1/products"/>
</route>

POST

HTTP POST for creating resources. The exchange body is sent as the request body.

XML
<route id="restPost">
    <from uri="direct:sendData"/>
    <to uri="pfx-rest:post?connection=myRestConn&amp;uri=/api/v1/orders&amp;contentType=application/json"/>
</route>

PUT

HTTP PUT for replacing resources. The exchange body is sent as the request body.

XML
<route id="restPut">
    <from uri="direct:updateData"/>
    <to uri="pfx-rest:put?connection=myRestConn&amp;uri=/api/v1/orders/123"/>
</route>

PATCH

HTTP PATCH for partial updates. The exchange body is sent as the request body.

XML
<route id="restPatch">
    <from uri="direct:patchData"/>
    <to uri="pfx-rest:patch?connection=myRestConn&amp;uri=/api/v1/orders/123"/>
</route>

DELETE

HTTP DELETE for removing resources.

XML
<route id="restDelete">
    <from uri="direct:deleteData"/>
    <to uri="pfx-rest:delete?connection=myRestConn&amp;uri=/api/v1/orders/123"/>
</route>

HTTP HEAD for retrieving response headers without a body.

XML
<route id="restHead">
    <from uri="direct:checkResource"/>
    <to uri="pfx-rest:head?connection=myRestConn&amp;uri=/api/v1/products/123"/>
</route>

OPTIONS

HTTP OPTIONS for discovering allowed methods and CORS preflight.

XML
<route id="restOptions">
    <from uri="direct:checkOptions"/>
    <to uri="pfx-rest:options?connection=myRestConn&amp;uri=/api/v1/products"/>
</route>

TRACE

HTTP TRACE for diagnostic/debugging purposes.

XML
<route id="restTrace">
    <from uri="direct:trace"/>
    <to uri="pfx-rest:trace?connection=myRestConn&amp;uri=/api/v1/debug"/>
</route>

system

Special method that reads configuration from system properties rather than inline parameters. Used for system-configuration-driven REST calls.

XML
<route id="restSystem">
    <from uri="direct:systemCall"/>
    <to uri="pfx-rest:system?systemName=externalERP&amp;systemConfigurationItem=fetchOrders"/>
</route>

URI Parameters

Core Parameters

Parameter

Type

Default

Description

method

String

(required, path)

HTTP method to use (get, post, put, delete, patch, head, options, trace, system)

uri

String


URI to invoke. If the connection does not specify a URL, provide the full path to the resource.

connection

String


Name of the connection to use for authentication and base URL resolution

contentType

String

application/json

Content type of the request

okStatusCodeRange

String

200-299

HTTP status codes considered a successful response

mapper

String


Mapper to apply to request/response

filter

String


Filter to apply

Input/Output Routing

Parameter

Type

Default

Description

inputSource

String


Source of data in the exchange: header, property, or body

inputSourceName

String


Name of the header or property when inputSource is header or property

outputTarget

String


Target for response data: header, property, or body

outputTargetName

String


Name of the header or property when outputTarget is header or property

Example -- read input from header, write output to header:

XML
<route id="restInputOutput">
    <from uri="direct:start"/>
    <setHeader name="requestPayload">
        <constant>{"key": "value"}</constant>
    </setHeader>
    <to uri="pfx-rest:post?connection=myRestConn&amp;uri=/api/v1/data&amp;inputSource=header&amp;inputSourceName=requestPayload&amp;outputTarget=header&amp;outputTargetName=responseData"/>
</route>

Proxy

Parameter

Type

Default

Description

proxyHost

String


Proxy host. Both proxyHost and proxyPort must be set together.

proxyPort

Integer


Proxy port. Both proxyHost and proxyPort must be set together.

Timeouts

Parameter

Type

Default

Description

connectionTimeoutMs

Long


Connection timeout in milliseconds (legacy parameter)

connectTimeoutMs

Long


Connection timeout in milliseconds for connecting to a target

soTimeoutMs

Long


Socket timeout in milliseconds for waiting for data

responseTimeoutMs

Long


Response timeout in milliseconds for waiting for a response

Connection Pooling and Keep-Alive

Parameter

Type

Default

Description

reuseConnection

Boolean


Reuse connections for subsequent requests to the same target

evictExpiredConnections

Boolean


Automatically evict expired connections from the pool

evictIdleConnections

Boolean


Automatically evict idle connections

evictIdleConnectionsMaxIdleTimeMs

Long


Maximum idle time (ms) before eviction

maxConnectionsTotal

Integer


Maximum total simultaneous connections in the pool

maxConnectionsPerRoute

Integer


Maximum simultaneous connections per route in the pool

soKeepAlive

Boolean


Enable SO_KEEPALIVE socket option

useMinimalKeepAliveStrategy

Boolean


Use a minimal keep-alive strategy for determining keep-alive duration

Streaming and File Upload

Parameter

Type

Default

Description

disableStreamCache

boolean

false

When true, content is streamed directly to file instead of stored in memory

downloadDir

String


Custom directory for downloaded files when disableStreamCache is enabled (defaults to temp dir)

autoDecode

boolean

true

Whether to auto-decode response content

fileKey

String

file

Key name for the file part in multipart uploads

useBoundary

boolean

true

Whether to use a boundary in multipart requests and content type

maxResponseSizeInMB

int

0 (unlimited)

Maximum response size in MB. Throws an exception if exceeded.

Example -- download large file with streaming:

XML
<route id="restDownload">
    <from uri="direct:downloadFile"/>
    <to uri="pfx-rest:get?connection=myRestConn&amp;uri=/api/v1/export&amp;disableStreamCache=true&amp;downloadDir=/tmp/downloads"/>
</route>

Example -- response size limit:

XML
<to uri="pfx-rest:get?connection=myRestConn&amp;uri=/api/v1/large-data&amp;maxResponseSizeInMB=50"/>

An exception is thrown if the response exceeds 50 MB.

Connection Behavior

Parameter

Type

Default

Description

failIfNoConnection

boolean

false

Whether to fail when a named connection is not found, or fall back to default behavior

System Configuration (method=system)

Parameter

Type

Description

systemName

String

System name

systemConfigurationItem

String

System configuration item

systemConfigurationProperties

Map

Additional system configuration properties (unmatched URI parameters are collected here)

Query Parameters

Unmatched URI parameters (those not recognized as component options) are automatically collected as query parameters and appended to the request URL:

XML
<route id="restGetWithParams">
    <from uri="direct:search"/>
    <to uri="pfx-rest:get?connection=myRestConn&amp;uri=/api/v1/search&amp;q=test&amp;limit=100"/>
</route>

Here, q and limit are passed as query parameters: /api/v1/search?q=test&limit=100.

Error Handling

  • HTTP responses outside the okStatusCodeRange result in an ExternalSystemException.

  • If failIfNoConnection=true and the named connection is not found, an exception is thrown.

  • Proxy misconfiguration (only one of proxyHost/proxyPort set) is detected by the proxyValid() check.

Common Pitfalls

Pitfall

Resolution

Forgetting &amp; in XML route URIs

In XML, & must be written as &amp; inside attribute values

Setting only proxyHost without proxyPort

Both must be set together; the proxyValid() check will reject partial configuration

Using connectionTimeoutMs for all timeouts

This is a legacy parameter. Prefer connectTimeoutMs, soTimeoutMs, and responseTimeoutMs for granular control.

Large response causes OOM

Set maxResponseSizeInMB to cap response size, or use disableStreamCache=true to stream to disk

Query params conflicting with component params

Named component parameters take priority. If your API has a query param with the same name as a component param (e.g., filter), use a workaround such as encoding it in the uri path directly.