Skip to content

rest-keycloak-soap-jms: encode JSON responses with the REST binding - #560

Merged
jamesnetherton merged 1 commit into
apache:camel-quarkus-mainfrom
jamesnetherton:rest-keycloak-soap-jms-json-encoding-and-error-handling
Aug 10, 2026
Merged

rest-keycloak-soap-jms: encode JSON responses with the REST binding#560
jamesnetherton merged 1 commit into
apache:camel-quarkus-mainfrom
jamesnetherton:rest-keycloak-soap-jms-json-encoding-and-error-handling

Conversation

@jamesnetherton

Copy link
Copy Markdown
Contributor

RestOrderRoute assembled its JSON response with String.format, interpolating the message returned by the SOAP service directly into a JSON template. Any quote or backslash in that message yields malformed JSON. This replaces it with an OrderResponse POJO encoded by the route's existing RestBindingMode.json binding.

The explicit Content-Type header is kept — after the CXF call the exchange carries text/xml, and the REST binding will not marshal to JSON without it.

KeycloakAdminRoute's error handler embedded ${exception.message} inside a constant(), so the placeholder was emitted literally instead of being resolved. Rather than switch to simple() — which would turn a latent bug into a genuine information leak — the response is now a static message and the exception detail stays in the log, which has been raised to ERROR.

The success-path test asserted only that the response string contained success and true, which passes on malformed JSON. It now asserts the parsed JSON fields, so the response has to be well-formed.

Verified with mvn clean verify -Dnative.

Claude Code on behalf of James Netherton

The order response was assembled with String.format, interpolating the
message returned by the SOAP service straight into a JSON template. A
quote or backslash in that message produces malformed JSON. Build an
OrderResponse instead and let the existing json binding mode encode it.

The Keycloak admin error handler embedded ${exception.message} in a
constant(), so the placeholder was emitted literally rather than
resolved. Return a static message and keep the exception detail in the
log, which now runs at ERROR level.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jamesnetherton
jamesnetherton merged commit 1d90e53 into apache:camel-quarkus-main Aug 10, 2026
4 checks passed
@jamesnetherton
jamesnetherton deleted the rest-keycloak-soap-jms-json-encoding-and-error-handling branch August 10, 2026 16:25
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