Methods
Complete reference for all HTTP methods supported by the
pfx-restcomponent, the full URI parameter list, and usage examples.
HTTP Methods
GET
Standard HTTP GET for retrieving resources.
<route id="restGet">
<from uri="direct:fetchData"/>
<to uri="pfx-rest:get?connection=myRestConn&uri=/api/v1/products"/>
</route>
POST
HTTP POST for creating resources. The exchange body is sent as the request body.
<route id="restPost">
<from uri="direct:sendData"/>
<to uri="pfx-rest:post?connection=myRestConn&uri=/api/v1/orders&contentType=application/json"/>
</route>
PUT
HTTP PUT for replacing resources. The exchange body is sent as the request body.
<route id="restPut">
<from uri="direct:updateData"/>
<to uri="pfx-rest:put?connection=myRestConn&uri=/api/v1/orders/123"/>
</route>
PATCH
HTTP PATCH for partial updates. The exchange body is sent as the request body.
<route id="restPatch">
<from uri="direct:patchData"/>
<to uri="pfx-rest:patch?connection=myRestConn&uri=/api/v1/orders/123"/>
</route>
DELETE
HTTP DELETE for removing resources.
<route id="restDelete">
<from uri="direct:deleteData"/>
<to uri="pfx-rest:delete?connection=myRestConn&uri=/api/v1/orders/123"/>
</route>
HEAD
HTTP HEAD for retrieving response headers without a body.
<route id="restHead">
<from uri="direct:checkResource"/>
<to uri="pfx-rest:head?connection=myRestConn&uri=/api/v1/products/123"/>
</route>
OPTIONS
HTTP OPTIONS for discovering allowed methods and CORS preflight.
<route id="restOptions">
<from uri="direct:checkOptions"/>
<to uri="pfx-rest:options?connection=myRestConn&uri=/api/v1/products"/>
</route>
TRACE
HTTP TRACE for diagnostic/debugging purposes.
<route id="restTrace">
<from uri="direct:trace"/>
<to uri="pfx-rest:trace?connection=myRestConn&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.
<route id="restSystem">
<from uri="direct:systemCall"/>
<to uri="pfx-rest:system?systemName=externalERP&systemConfigurationItem=fetchOrders"/>
</route>
URI Parameters
Core Parameters
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
(required, path) |
HTTP method to use (get, post, put, delete, patch, head, options, trace, system) |
|
|
|
|
URI to invoke. If the connection does not specify a URL, provide the full path to the resource. |
|
|
|
|
Name of the connection to use for authentication and base URL resolution |
|
|
|
|
Content type of the request |
|
|
|
|
HTTP status codes considered a successful response |
|
|
|
|
Mapper to apply to request/response |
|
|
|
|
Filter to apply |
Input/Output Routing
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
Source of data in the exchange: |
|
|
|
|
Name of the header or property when |
|
|
|
|
Target for response data: |
|
|
|
|
Name of the header or property when |
Example -- read input from header, write output to header:
<route id="restInputOutput">
<from uri="direct:start"/>
<setHeader name="requestPayload">
<constant>{"key": "value"}</constant>
</setHeader>
<to uri="pfx-rest:post?connection=myRestConn&uri=/api/v1/data&inputSource=header&inputSourceName=requestPayload&outputTarget=header&outputTargetName=responseData"/>
</route>
Proxy
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
Proxy host. Both |
|
|
|
|
Proxy port. Both |
Timeouts
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
Connection timeout in milliseconds (legacy parameter) |
|
|
|
|
Connection timeout in milliseconds for connecting to a target |
|
|
|
|
Socket timeout in milliseconds for waiting for data |
|
|
|
|
Response timeout in milliseconds for waiting for a response |
Connection Pooling and Keep-Alive
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
Reuse connections for subsequent requests to the same target |
|
|
|
|
Automatically evict expired connections from the pool |
|
|
|
|
Automatically evict idle connections |
|
|
|
|
Maximum idle time (ms) before eviction |
|
|
|
|
Maximum total simultaneous connections in the pool |
|
|
|
|
Maximum simultaneous connections per route in the pool |
|
|
|
|
Enable SO_KEEPALIVE socket option |
|
|
|
|
Use a minimal keep-alive strategy for determining keep-alive duration |
Streaming and File Upload
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
When |
|
|
|
|
Custom directory for downloaded files when |
|
|
|
|
Whether to auto-decode response content |
|
|
|
|
Key name for the file part in multipart uploads |
|
|
|
|
Whether to use a boundary in multipart requests and content type |
|
|
|
|
Maximum response size in MB. Throws an exception if exceeded. |
Example -- download large file with streaming:
<route id="restDownload">
<from uri="direct:downloadFile"/>
<to uri="pfx-rest:get?connection=myRestConn&uri=/api/v1/export&disableStreamCache=true&downloadDir=/tmp/downloads"/>
</route>
Example -- response size limit:
<to uri="pfx-rest:get?connection=myRestConn&uri=/api/v1/large-data&maxResponseSizeInMB=50"/>
An exception is thrown if the response exceeds 50 MB.
Connection Behavior
|
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
|
|
Whether to fail when a named connection is not found, or fall back to default behavior |
System Configuration (method=system)
|
Parameter |
Type |
Description |
|---|---|---|
|
|
|
System name |
|
|
|
System configuration item |
|
|
|
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:
<route id="restGetWithParams">
<from uri="direct:search"/>
<to uri="pfx-rest:get?connection=myRestConn&uri=/api/v1/search&q=test&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
okStatusCodeRangeresult in anExternalSystemException. -
If
failIfNoConnection=trueand the named connection is not found, an exception is thrown. -
Proxy misconfiguration (only one of
proxyHost/proxyPortset) is detected by theproxyValid()check.
Common Pitfalls
|
Pitfall |
Resolution |
|---|---|
|
Forgetting |
In XML, |
|
Setting only |
Both must be set together; the |
|
Using |
This is a legacy parameter. Prefer |
|
Large response causes OOM |
Set |
|
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., |