Skip to content

Fix rest-cxf example: use CamelCxfOperationName for dynamic bean dispatch - #206

Open
Croway wants to merge 2 commits into
apache:mainfrom
Croway:fix-rest-cxf-operation-name
Open

Fix rest-cxf example: use CamelCxfOperationName for dynamic bean dispatch#206
Croway wants to merge 2 commits into
apache:mainfrom
Croway:fix-rest-cxf-operation-name

Conversation

@Croway

@Croway Croway commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • CamelRouter in the rest-cxf example dispatched on ${header.operationName}, a header that CXF-RS never sets. DefaultCxfRsBinding actually populates CamelCxfOperationName for every cxfrs request regardless of binding style, so the header resolved empty and every GET/PUT hit bean:userServiceImpl?method= with a blank method name, throwing MethodNotFoundException (500). Only the bean-validation error path worked, since it short-circuits before the dynamic dispatch. This is a pre-existing bug, not a regression from any recent bump.
  • Fixed by routing on ${header.CamelCxfOperationName}, matching what the sibling soap-cxf example already does correctly.
  • Kept toD (rather than switching to recipientList) since there is exactly one computed destination per exchange here — toD is the EIP built for that case, whereas recipientList is designed for multicasting to potentially several recipients.

Test plan

  • mvn -pl rest-cxf -am package
  • Ran the app (mvn spring-boot:run) and exercised all documented endpoints:
    • GET /services/api/user → 200, list of users
    • GET /services/api/user/1 → 200, single user
    • PUT /services/api/user (valid payload) → 201
    • PUT /services/api/user (invalid payload) → 400 with validation message (already worked before, still works)

🤖 Generated with Claude Code

Croway and others added 2 commits September 4, 2026 09:38
…dispatch

CamelRouter routed on ${header.operationName}, a header CXF-RS never sets;
DefaultCxfRsBinding populates CamelCxfOperationName instead, so the header
resolved empty and every GET/PUT hit MethodNotFoundException (500). Only
the bean-validation error path worked, since it short-circuits before the
dynamic dispatch.

Use ${header.CamelCxfOperationName}, and switch to recipientList to match
the idiom documented in the cxfrs component docs and already used by the
sibling soap-cxf example, instead of toD.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvQJNT1UYzqUm5HQtkL6Nu
recipientList is designed for multicasting to potentially several
recipients; here there is exactly one computed destination per
exchange, which is exactly what toD is for.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvQJNT1UYzqUm5HQtkL6Nu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant