Metadata
- Applicable Version:
PlatformHttp@v3.0.0 - Related Service:
PlatformHttp@v3.0.0@platform-http-route.xml
PlatformHttp v3.0.0 provides a compact and practical HTTP transform pattern: receive order JSON, extract business fields with JSONPath, and return JSON responses with consistent encoding.
This article walks through how the route is designed and how to validate it quickly.
Background and Goal
In many integration services, the request entry must be strict and observable:
- Keep a clear HTTP Listener entry for upstream systems
- Extract key fields (
orderId) as early as possible - Preserve service-level logs for troubleshooting
- Return stable JSON without Chinese encoding issues
PlatformHttp v3.0.0 addresses these goals in one route package.
Route and Configuration Breakdown
1) Runtime listener switch and port
From common.config.properties:
server.port=18080
HTTP.Listener=true
system.components=undertowhttp
Meaning:
-
HTTP.Listener=trueenables Undertow registration -
server.port=18080defines the external listening port - route endpoint resolves with this port at runtime
2) Service identity and URL versioning
From service.config.properties:
service.name=PlatformHttp
service.version=3.0.0
The main request entry uses:
<from uri="undertow:http://0.0.0.0:{{server.port}}/{{service.version}}/transform/order?httpMethodRestrict=POST" />
So the final request path is:
POST /3.0.0/transform/order
This keeps API versioning explicit in URL paths.
3) JSONPath extraction and response write-back
The route extracts orderId in multiple ways, then writes a JSON response:
<log message="orderId (JSONPath): ${jsonpath($.orderId)}"/>
<setProperty name="extractedOrderId"><jsonpath>$.orderId</jsonpath></setProperty>
<setHeader name="OrderId"><jsonpath>$.orderId</jsonpath></setHeader>
...
<transform><simple>{"status": "success", "message": "请求处理完成"}</simple></transform>
<process ref="jsonResponseProcessor"/>
<setHeader name="Content-Type"><constant>application/json</constant></setHeader>
Why this design works:
- HTTP Listener: one explicit request entry point
-
Request entry observability:
servicelogcaptures headers and body - Downstream forwarding ready: extracted fields can be reused for later routing decisions
-
Response write-back stability:
jsonResponseProcessorimproves UTF-8 output behavior
Request and Response Validation
API 1: Main transform route
curl -X POST "http://localhost:18080/3.0.0/transform/order" \
-H "Content-Type: application/json" \
-d "{\"orderId\":\"ORD-20260409-001\",\"amount\":299.50}"
Expected response:
{"status":"success","message":"请求处理完成"}
API 2: JSONPath-inline response sample
curl -X POST "http://localhost:18080/3.0.0/transform/order1" \
-H "Content-Type: application/json" \
-d "{\"orderId\":\"ORD-20260409-002\"}"
Expected response:
{"status":"ORD-20260409-002","message":"请求处理完成"}
Common Issues and Troubleshooting
1) Port not reachable
Check:
HTTP.Listener=trueserver.port=18080- no other process occupies
18080
2) Method rejected (405)
- the endpoint restricts method with
httpMethodRestrict=POST - call must use
POST
3) Incorrect path or version
- route path includes
{{service.version}} - ensure request URL matches
/3.0.0/transform/orderor/3.0.0/transform/order1
4) Encoding or garbled response text
- keep
jsonResponseProcessorin the response path - keep
Content-Type: application/jsonresponse header
Summary
PlatformHttp v3.0.0 demonstrates a practical baseline for API integration routes:
- strict HTTP Listener entry
- early JSONPath field extraction
- service-level request tracing
- stable UTF-8 response write-back
This pattern is suitable for order transform gateways and can be extended with validation, auth checks, and downstream forwarding policies.
Top comments (0)