This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new 237097772 chore: soap-source answers a SOAP fault built as text,
soap-action address is optional, WS-Security UsernameToken options
(CAMEL-27372, CAMEL-27374, CAMEL-27373, CAMEL-27364) (#3356)
237097772 is described below
commit 237097772de0c9d78b65080c4283404448e923f3
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 22 17:25:54 2026 +0100
chore: soap-source answers a SOAP fault built as text, soap-action address
is optional, WS-Security UsernameToken options (CAMEL-27372, CAMEL-27374,
CAMEL-27373, CAMEL-27364) (#3356)
* chore: soap-source answers a SOAP fault the route builds as text, and
soap-action address is optional with a WSDL that has one (CAMEL-27372,
CAMEL-27374)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: soap-action and soap-source WS-Security UsernameToken options
(CAMEL-27373)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: soap-action no longer needs --dep=camel:cxf-soap to catch a
SoapFault (CAMEL-27364), the password type must match, and the tests check the
no-address call by its order
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: the WS-Security test checks the reply by its order, as CXF adds
the soap namespace to the body
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
* chore: soap-action says that a refused UsernameToken gives a
SecurityError fault
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
kamelets/soap-action.kamelet.yaml | 26 +++++-
kamelets/soap-source.kamelet.yaml | 29 ++++--
.../main/resources/META-INF/kamelets-index.json | 4 +-
.../resources/kamelets/soap-action.kamelet.yaml | 26 +++++-
.../resources/kamelets/soap-source.kamelet.yaml | 29 ++++--
.../camel-kamelets-itest/src/test/java/SoapIT.java | 2 +
.../test/resources/soap/soap-backend-route.yaml | 5 +
.../soap/soap-front-backend.citrus.it.yaml | 43 ++++++++-
.../src/test/resources/soap/soap-front-route.yaml | 33 +++++--
.../test/resources/soap/soap-soap12.citrus.it.yaml | 20 +++-
.../src/test/resources/soap/soap-wssec-route.yaml | 101 +++++++++++++++++++++
.../test/resources/soap/soap-wssec.citrus.it.yaml | 79 ++++++++++++++++
.../src/test/resources/soap/soap12-route.yaml | 5 +
13 files changed, 369 insertions(+), 33 deletions(-)
diff --git a/kamelets/soap-action.kamelet.yaml
b/kamelets/soap-action.kamelet.yaml
index 200312a7f..1366a2009 100644
--- a/kamelets/soap-action.kamelet.yaml
+++ b/kamelets/soap-action.kamelet.yaml
@@ -40,16 +40,15 @@ spec:
Output: the body is the content of the SOAP Body of the response as XML
text: the response element of the operation, such as `<getOrderResponse
xmlns="http://example.com/orders">...</getOrderResponse>`.
- Good to know: a SOAP fault from the service fails the message with an
`org.apache.cxf.binding.soap.SoapFault` error, whose message is the text of the
fault; with Camel JBang, a route that catches this error by its class name
needs the dependency `camel:cxf-soap`. When `faultAsBody` is true, the message
goes on instead: the body is the content of the `detail` element of the fault
as XML text, such as the fault element the WSDL declares (no body when the
fault has no detail), the hea [...]
+ Good to know: a SOAP fault from the service fails the message with an
`org.apache.cxf.binding.soap.SoapFault` error, whose message is the text of the
fault, so that a route can catch it by its class name. When `faultAsBody` is
true, the message goes on instead: the body is the content of the `detail`
element of the fault as XML text, such as the fault element the WSDL declares
(no body when the fault has no detail), the header `SoapFault` is the text of
the fault, and `SoapFaultCod [...]
required:
- - address
- wsdlURL
- operation
type: object
properties:
address:
title: Address
- description: The URL of the SOAP service.
+ description: The URL of the SOAP service. When it is not set, the
address that the WSDL gives for the port is called, the `location` of its
`soap:address`.
type: string
example: "https://legacy.example.com/orders"
pattern: "^https?://.+"
@@ -99,6 +98,25 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ wsSecurityUsername:
+ title: WS-Security Username
+ description: The user name to send in a WS-Security UsernameToken, in
the SOAP header of each request, for a service that requires one. It is not the
same as `username`, which is for HTTP Basic authentication. Set
`wsSecurityPassword` too.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPassword:
+ title: WS-Security Password
+ description: The password of `wsSecurityUsername`, sent in the
UsernameToken.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPasswordType:
+ title: WS-Security Password Type
+ description: How the UsernameToken carries the password. `Text` sends
it as it is, so only use it over HTTPS. `Digest` sends a SHA-1 digest of it,
which is no replacement for HTTPS. It must be the type the service requires, or
the service refuses the token. When the WSDL has a WS-SecurityPolicy, the
policy decides instead. When it is not set, `Text`.
+ type: string
+ enum: ["Text", "Digest"]
+ example: Digest
dataTypes:
# No 'default:' on purpose: the body is the XML of the request and of the
response, as it is. See #3117.
in:
@@ -129,7 +147,7 @@ spec:
- doTry:
steps:
- to:
- uri:
"cxf://{{address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&dataFormat=PAYLOAD&defaultOperationName={{operation}}&defaultOperationNamespace={{?operationNamespace}}&username=RAW({{?username}})&password=RAW({{?password}})"
+ uri:
"cxf://{{?address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&dataFormat=PAYLOAD&defaultOperationName={{operation}}&defaultOperationNamespace={{?operationNamespace}}&username=RAW({{?username}})&password=RAW({{?password}})&wsSecurityUsername=RAW({{?wsSecurityUsername}})&wsSecurityPassword=RAW({{?wsSecurityPassword}})&wsSecurityPasswordType={{?wsSecurityPasswordType}}"
- convertBodyTo:
type: java.lang.String
- doCatch:
diff --git a/kamelets/soap-source.kamelet.yaml
b/kamelets/soap-source.kamelet.yaml
index 4accb9ff9..2cfbebb66 100644
--- a/kamelets/soap-source.kamelet.yaml
+++ b/kamelets/soap-source.kamelet.yaml
@@ -38,9 +38,9 @@ spec:
Output: the body is the content of the SOAP Body of the request as XML
text: the request element of the operation, such as `<getOrder
xmlns="http://example.com/orders"><orderId>7</orderId></getOrder>`. The header
`CamelCxfOperationName` is the name of the operation, such as `getOrder`, and
`CamelCxfOperationNamespace` its namespace. The HTTP headers of the request,
such as `User-Agent`, are headers too.
- The reply of the route, as XML text, is the content of the SOAP Body of
the response: the response element of the operation, such as `<getOrderResponse
xmlns="http://example.com/orders">...</getOrderResponse>`. To answer with a
SOAP fault, the route sets the header `SoapFault` to the text of the fault, and
`SoapFaultCode` to `Client` when the request was wrong (`Sender` with SOAP 1.2;
otherwise the code is `Server`, or `Receiver`); the body, if any, is the
content of the detail of [...]
+ The reply of the route, as XML text, is the content of the SOAP Body of
the response: the response element of the operation, such as `<getOrderResponse
xmlns="http://example.com/orders">...</getOrderResponse>`. To answer with a
SOAP fault, the route sets the header `SoapFault` to the text of the fault, and
`SoapFaultCode` to `Client` when the request was wrong (`Sender` with SOAP 1.2;
otherwise the code is `Server`, or `Receiver`); the body, if any, is the
content of the detail of [...]
- Good to know: the service is served at `address`, its WSDL at `address`
followed by `?wsdl`, with SOAP 1.1 or 1.2 as the WSDL says. A request or a
reply that does not match the XML schema of the WSDL is refused with a SOAP
fault, unless `schemaValidation` is false, and so is a request for an operation
the WSDL does not have, and a request with a DOCTYPE. There is no login:
protect the address with your network. To work with JSON, turn the body into
JSON with `xj-identity-action`, a [...]
+ Good to know: the service is served at `address`, its WSDL at `address`
followed by `?wsdl`, with SOAP 1.1 or 1.2 as the WSDL says. A request or a
reply that does not match the XML schema of the WSDL is refused with a SOAP
fault, unless `schemaValidation` is false, and so is a request for an operation
the WSDL does not have, and a request with a DOCTYPE. There is no login unless
`wsSecurityUsername` and `wsSecurityPassword` are set, which require a
WS-Security UsernameToken in each [...]
required:
- address
- wsdlURL
@@ -81,6 +81,25 @@ spec:
description: Whether to refuse a request, and a reply of the route,
that does not match the XML schema of the WSDL.
type: boolean
default: true
+ wsSecurityUsername:
+ title: WS-Security Username
+ description: The user that may call the service. When it is set, each
request must carry a WS-Security UsernameToken of this user and
`wsSecurityPassword` in its SOAP header, or it is refused with a SOAP fault
before the route sees it.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPassword:
+ title: WS-Security Password
+ description: The password of `wsSecurityUsername`.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPasswordType:
+ title: WS-Security Password Type
+ description: How the UsernameToken must carry the password. `Text` as
it is, so only use it over HTTPS, or `Digest` as a SHA-1 digest of it, which is
no replacement for HTTPS. A UsernameToken with the other type is refused. When
the WSDL has a WS-SecurityPolicy, the policy decides instead. When it is not
set, `Text`.
+ type: string
+ enum: ["Text", "Digest"]
+ example: Digest
loggingEnabled:
title: Log Messages
description: Whether to write each SOAP request and response to the
log. Do not turn it on when the messages hold personal data or secrets.
@@ -103,7 +122,7 @@ spec:
- "camel:kamelet"
template:
from:
- uri:
"cxf://{{address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&publishedEndpointUrl=RAW({{?publishedEndpointUrl}})&dataFormat=PAYLOAD&schemaValidationEnabled={{schemaValidation}}&loggingFeatureEnabled={{loggingEnabled}}"
+ uri:
"cxf://{{address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&publishedEndpointUrl=RAW({{?publishedEndpointUrl}})&dataFormat=PAYLOAD&schemaValidationEnabled={{schemaValidation}}&loggingFeatureEnabled={{loggingEnabled}}&wsSecurityUsername=RAW({{?wsSecurityUsername}})&wsSecurityPassword=RAW({{?wsSecurityPassword}})&wsSecurityPasswordType={{?wsSecurityPasswordType}}"
steps:
# The headers that make the reply a fault come from the route, never
from the client. CamelHttp* would
# steer an HTTP call later in the route, and CamelCxfMessage is the
whole internal CXF message.
@@ -155,6 +174,4 @@ spec:
expression:
simple:
expression: "<soap:Fault
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><faultcode>soap:${variable.soapSourceFaultCode
== 'Client' ? 'Client' : 'Server'}</faultcode><faultstring>${escape(xml,
${variable.soapSourceFault})}</faultstring><detail>${body}</detail></soap:Fault>"
- # As a CXF payload, the consumer returns it as a SOAP fault;
as text it would be a normal reply.
- - convertBodyTo:
- type: org.apache.camel.component.cxf.common.CxfPayload
+ # The consumer returns a Fault element, also as text, as a
SOAP fault (CAMEL-27372).
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index e2bf43214..8a886d6db 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -2075,7 +2075,7 @@
"supportLevel" : "Preview",
"title" : "SOAP Action",
"summary" : "Calls an operation of a SOAP web service described by a WSDL
file for each message, and gives back the response.",
- "description" : "Calls an operation of a SOAP web service described by a
WSDL file for each message, and gives back the response.\n\nUse it to call an
existing SOAP service from a route, such as an order or customer service of an
older system, with XML and without generating Java code from the WSDL. To serve
a SOAP service, use `soap-source`.\n\nInput: the body is the request element of
the operation as XML text, such as `<getOrder
xmlns=\"http://example.com/orders\"><orderId>7</orde [...]
+ "description" : "Calls an operation of a SOAP web service described by a
WSDL file for each message, and gives back the response.\n\nUse it to call an
existing SOAP service from a route, such as an order or customer service of an
older system, with XML and without generating Java code from the WSDL. To serve
a SOAP service, use `soap-source`.\n\nInput: the body is the request element of
the operation as XML text, such as `<getOrder
xmlns=\"http://example.com/orders\"><orderId>7</orde [...]
"group" : "SOAP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
@@ -2085,7 +2085,7 @@
"supportLevel" : "Preview",
"title" : "SOAP Source",
"summary" : "Serves a SOAP web service described by a WSDL file, and
answers each call with the reply of the route.",
- "description" : "Serves a SOAP web service described by a WSDL file, and
answers each call with the reply of the route.\n\nUse it to keep existing SOAP
clients working while the systems behind the service are replaced: the route
gets each call and can call REST services or other systems to answer it. No
Java code is generated from the WSDL. To call a SOAP service, use
`soap-action`.\n\nOutput: the body is the content of the SOAP Body of the
request as XML text: the request element of [...]
+ "description" : "Serves a SOAP web service described by a WSDL file, and
answers each call with the reply of the route.\n\nUse it to keep existing SOAP
clients working while the systems behind the service are replaced: the route
gets each call and can call REST services or other systems to answer it. No
Java code is generated from the WSDL. To call a SOAP service, use
`soap-action`.\n\nOutput: the body is the content of the SOAP Body of the
request as XML text: the request element of [...]
"group" : "SOAP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/soap-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/soap-action.kamelet.yaml
index 200312a7f..1366a2009 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/soap-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/soap-action.kamelet.yaml
@@ -40,16 +40,15 @@ spec:
Output: the body is the content of the SOAP Body of the response as XML
text: the response element of the operation, such as `<getOrderResponse
xmlns="http://example.com/orders">...</getOrderResponse>`.
- Good to know: a SOAP fault from the service fails the message with an
`org.apache.cxf.binding.soap.SoapFault` error, whose message is the text of the
fault; with Camel JBang, a route that catches this error by its class name
needs the dependency `camel:cxf-soap`. When `faultAsBody` is true, the message
goes on instead: the body is the content of the `detail` element of the fault
as XML text, such as the fault element the WSDL declares (no body when the
fault has no detail), the hea [...]
+ Good to know: a SOAP fault from the service fails the message with an
`org.apache.cxf.binding.soap.SoapFault` error, whose message is the text of the
fault, so that a route can catch it by its class name. When `faultAsBody` is
true, the message goes on instead: the body is the content of the `detail`
element of the fault as XML text, such as the fault element the WSDL declares
(no body when the fault has no detail), the header `SoapFault` is the text of
the fault, and `SoapFaultCod [...]
required:
- - address
- wsdlURL
- operation
type: object
properties:
address:
title: Address
- description: The URL of the SOAP service.
+ description: The URL of the SOAP service. When it is not set, the
address that the WSDL gives for the port is called, the `location` of its
`soap:address`.
type: string
example: "https://legacy.example.com/orders"
pattern: "^https?://.+"
@@ -99,6 +98,25 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ wsSecurityUsername:
+ title: WS-Security Username
+ description: The user name to send in a WS-Security UsernameToken, in
the SOAP header of each request, for a service that requires one. It is not the
same as `username`, which is for HTTP Basic authentication. Set
`wsSecurityPassword` too.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPassword:
+ title: WS-Security Password
+ description: The password of `wsSecurityUsername`, sent in the
UsernameToken.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPasswordType:
+ title: WS-Security Password Type
+ description: How the UsernameToken carries the password. `Text` sends
it as it is, so only use it over HTTPS. `Digest` sends a SHA-1 digest of it,
which is no replacement for HTTPS. It must be the type the service requires, or
the service refuses the token. When the WSDL has a WS-SecurityPolicy, the
policy decides instead. When it is not set, `Text`.
+ type: string
+ enum: ["Text", "Digest"]
+ example: Digest
dataTypes:
# No 'default:' on purpose: the body is the XML of the request and of the
response, as it is. See #3117.
in:
@@ -129,7 +147,7 @@ spec:
- doTry:
steps:
- to:
- uri:
"cxf://{{address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&dataFormat=PAYLOAD&defaultOperationName={{operation}}&defaultOperationNamespace={{?operationNamespace}}&username=RAW({{?username}})&password=RAW({{?password}})"
+ uri:
"cxf://{{?address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&dataFormat=PAYLOAD&defaultOperationName={{operation}}&defaultOperationNamespace={{?operationNamespace}}&username=RAW({{?username}})&password=RAW({{?password}})&wsSecurityUsername=RAW({{?wsSecurityUsername}})&wsSecurityPassword=RAW({{?wsSecurityPassword}})&wsSecurityPasswordType={{?wsSecurityPasswordType}}"
- convertBodyTo:
type: java.lang.String
- doCatch:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/soap-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/soap-source.kamelet.yaml
index 4accb9ff9..2cfbebb66 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/soap-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/soap-source.kamelet.yaml
@@ -38,9 +38,9 @@ spec:
Output: the body is the content of the SOAP Body of the request as XML
text: the request element of the operation, such as `<getOrder
xmlns="http://example.com/orders"><orderId>7</orderId></getOrder>`. The header
`CamelCxfOperationName` is the name of the operation, such as `getOrder`, and
`CamelCxfOperationNamespace` its namespace. The HTTP headers of the request,
such as `User-Agent`, are headers too.
- The reply of the route, as XML text, is the content of the SOAP Body of
the response: the response element of the operation, such as `<getOrderResponse
xmlns="http://example.com/orders">...</getOrderResponse>`. To answer with a
SOAP fault, the route sets the header `SoapFault` to the text of the fault, and
`SoapFaultCode` to `Client` when the request was wrong (`Sender` with SOAP 1.2;
otherwise the code is `Server`, or `Receiver`); the body, if any, is the
content of the detail of [...]
+ The reply of the route, as XML text, is the content of the SOAP Body of
the response: the response element of the operation, such as `<getOrderResponse
xmlns="http://example.com/orders">...</getOrderResponse>`. To answer with a
SOAP fault, the route sets the header `SoapFault` to the text of the fault, and
`SoapFaultCode` to `Client` when the request was wrong (`Sender` with SOAP 1.2;
otherwise the code is `Server`, or `Receiver`); the body, if any, is the
content of the detail of [...]
- Good to know: the service is served at `address`, its WSDL at `address`
followed by `?wsdl`, with SOAP 1.1 or 1.2 as the WSDL says. A request or a
reply that does not match the XML schema of the WSDL is refused with a SOAP
fault, unless `schemaValidation` is false, and so is a request for an operation
the WSDL does not have, and a request with a DOCTYPE. There is no login:
protect the address with your network. To work with JSON, turn the body into
JSON with `xj-identity-action`, a [...]
+ Good to know: the service is served at `address`, its WSDL at `address`
followed by `?wsdl`, with SOAP 1.1 or 1.2 as the WSDL says. A request or a
reply that does not match the XML schema of the WSDL is refused with a SOAP
fault, unless `schemaValidation` is false, and so is a request for an operation
the WSDL does not have, and a request with a DOCTYPE. There is no login unless
`wsSecurityUsername` and `wsSecurityPassword` are set, which require a
WS-Security UsernameToken in each [...]
required:
- address
- wsdlURL
@@ -81,6 +81,25 @@ spec:
description: Whether to refuse a request, and a reply of the route,
that does not match the XML schema of the WSDL.
type: boolean
default: true
+ wsSecurityUsername:
+ title: WS-Security Username
+ description: The user that may call the service. When it is set, each
request must carry a WS-Security UsernameToken of this user and
`wsSecurityPassword` in its SOAP header, or it is refused with a SOAP fault
before the route sees it.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPassword:
+ title: WS-Security Password
+ description: The password of `wsSecurityUsername`.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
+ wsSecurityPasswordType:
+ title: WS-Security Password Type
+ description: How the UsernameToken must carry the password. `Text` as
it is, so only use it over HTTPS, or `Digest` as a SHA-1 digest of it, which is
no replacement for HTTPS. A UsernameToken with the other type is refused. When
the WSDL has a WS-SecurityPolicy, the policy decides instead. When it is not
set, `Text`.
+ type: string
+ enum: ["Text", "Digest"]
+ example: Digest
loggingEnabled:
title: Log Messages
description: Whether to write each SOAP request and response to the
log. Do not turn it on when the messages hold personal data or secrets.
@@ -103,7 +122,7 @@ spec:
- "camel:kamelet"
template:
from:
- uri:
"cxf://{{address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&publishedEndpointUrl=RAW({{?publishedEndpointUrl}})&dataFormat=PAYLOAD&schemaValidationEnabled={{schemaValidation}}&loggingFeatureEnabled={{loggingEnabled}}"
+ uri:
"cxf://{{address}}?wsdlURL=RAW({{wsdlURL}})&serviceName={{?serviceName}}&portName={{?portName}}&publishedEndpointUrl=RAW({{?publishedEndpointUrl}})&dataFormat=PAYLOAD&schemaValidationEnabled={{schemaValidation}}&loggingFeatureEnabled={{loggingEnabled}}&wsSecurityUsername=RAW({{?wsSecurityUsername}})&wsSecurityPassword=RAW({{?wsSecurityPassword}})&wsSecurityPasswordType={{?wsSecurityPasswordType}}"
steps:
# The headers that make the reply a fault come from the route, never
from the client. CamelHttp* would
# steer an HTTP call later in the route, and CamelCxfMessage is the
whole internal CXF message.
@@ -155,6 +174,4 @@ spec:
expression:
simple:
expression: "<soap:Fault
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><faultcode>soap:${variable.soapSourceFaultCode
== 'Client' ? 'Client' : 'Server'}</faultcode><faultstring>${escape(xml,
${variable.soapSourceFault})}</faultstring><detail>${body}</detail></soap:Fault>"
- # As a CXF payload, the consumer returns it as a SOAP fault;
as text it would be a normal reply.
- - convertBodyTo:
- type: org.apache.camel.component.cxf.common.CxfPayload
+ # The consumer returns a Fault element, also as text, as a
SOAP fault (CAMEL-27372).
diff --git a/tests/camel-kamelets-itest/src/test/java/SoapIT.java
b/tests/camel-kamelets-itest/src/test/java/SoapIT.java
index efe2f595b..b3b621d00 100644
--- a/tests/camel-kamelets-itest/src/test/java/SoapIT.java
+++ b/tests/camel-kamelets-itest/src/test/java/SoapIT.java
@@ -37,6 +37,7 @@ public class SoapIT {
private final int backendPort = ServerPorts.next();
private final int frontPort = ServerPorts.next();
private final int soap12Port = ServerPorts.next();
+ private final int wssecPort = ServerPorts.next();
@BindToRegistry
public SequenceBeforeTest beforeSoap() {
@@ -45,6 +46,7 @@ public class SoapIT {
.variable("soap.backend.port",
String.valueOf(backendPort))
.variable("soap.front.port", String.valueOf(frontPort))
.variable("soap.soap12.port",
String.valueOf(soap12Port))
+ .variable("soap.wssec.port", String.valueOf(wssecPort))
).build();
}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-backend-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-backend-route.yaml
index 30c227821..55b1c8b34 100644
--- a/tests/camel-kamelets-itest/src/test/resources/soap/soap-backend-route.yaml
+++ b/tests/camel-kamelets-itest/src/test/resources/soap/soap-backend-route.yaml
@@ -41,6 +41,11 @@
constant: "Client"
- setBody:
simple: '<orderNotFound
xmlns="http://example.com/orders"><orderId>${variable.orderId}</orderId></orderNotFound>'
+ # the route builds the SOAP fault itself, as XML text, with no
SoapFault header
+ - simple: "${variable.orderId} == '409'"
+ steps:
+ - setBody:
+ simple: '<soap:Fault
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Client</faultcode><faultstring>Order
${variable.orderId} is locked</faultstring><detail><orderNotFound
xmlns="http://example.com/orders"><orderId>${variable.orderId}</orderId></orderNotFound></detail></soap:Fault>'
# a failure of the route: the client must not learn why
- simple: "${variable.orderId} == '500'"
steps:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-backend.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-backend.citrus.it.yaml
index dc463c449..e98f81206 100644
---
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-backend.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-backend.citrus.it.yaml
@@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------
name: soap-front-backend-test
-description: 'soap-source serves a SOAP front that calls a legacy SOAP service
with soap-action: a reply, a declared fault passed on, a muted route failure, a
DOCTYPE refused'
+description: 'soap-source serves a SOAP front that calls a legacy SOAP service
with soap-action: a reply, a call with no address to the address of the WSDL, a
declared fault passed on, a fault the route builds as text, a muted route
failure, a DOCTYPE refused'
actions:
# The legacy service, then the front that calls it
- camel:
@@ -75,6 +75,29 @@ actions:
integration: "soap-backend-route"
logMessage: 'Backend getOrder
SOAPAction=http://example.com/orders/getOrder Authorization=Basic
ZnJvbnQ6czNjcmV0: <getOrder xmlns="http://example.com/orders"'
+ # soap-action with no address calls the address that the WSDL of the legacy
service gives
+ - http:
+ client: "http://localhost:${soap.front.port}"
+ sendRequest:
+ POST:
+ path: "/orders"
+ contentType: "text/xml"
+ body:
+ data: '<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><o:getOrder
xmlns:o="http://example.com/orders"><o:orderId>8</o:orderId></o:getOrder></soap:Body></soap:Envelope>'
+ - http:
+ client: "http://localhost:${soap.front.port}"
+ receiveResponse:
+ response:
+ status: 200
+ type: "plaintext"
+ body:
+ data:
'@contains(''<order><orderId>8</orderId><customer>ACME</customer><status>shipped</status>'')@'
+ - camel:
+ cli:
+ verify:
+ integration: "soap-backend-route"
+ logMessage: '<orderId>8</orderId></getOrder>'
+
# The declared fault of the legacy service, passed on by the front with its
detail
- http:
client: "http://localhost:${soap.front.port}"
@@ -116,6 +139,24 @@ actions:
body:
data:
'@contains(''<soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exchange
processing failed</faultstring><detail/></soap:Fault>'')@'
+ # The legacy route replies with a SOAP fault it built as XML text: the
client gets it as a fault
+ - http:
+ client: "http://localhost:${soap.backend.port}"
+ sendRequest:
+ POST:
+ path: "/orders"
+ contentType: "text/xml"
+ body:
+ data: '<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><o:getOrder
xmlns:o="http://example.com/orders"><o:orderId>409</o:orderId></o:getOrder></soap:Body></soap:Envelope>'
+ - http:
+ client: "http://localhost:${soap.backend.port}"
+ receiveResponse:
+ response:
+ status: 500
+ type: "plaintext"
+ body:
+ data: '<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Order
409 is locked</faultstring><detail><orderNotFound
xmlns="http://example.com/orders"><orderId>409</orderId></orderNotFound></detail></soap:Fault></soap:Body></soap:Envelope>'
+
# A failure of the legacy route: the fault does not say why
- http:
client: "http://localhost:${soap.backend.port}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-route.yaml
index aa1230af5..ca76adc53 100644
--- a/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-route.yaml
+++ b/tests/camel-kamelets-itest/src/test/resources/soap/soap-front-route.yaml
@@ -48,15 +48,30 @@
- setHeader:
name: "Authorization"
constant: "Basic dXNlcjpzZWNyZXQ="
- - to:
- uri: "kamelet:soap-action"
- parameters:
- address: "http://localhost:{{soap.backend.port}}/orders"
- wsdlURL: "classpath:orders.wsdl"
- operation: "getOrder"
- faultAsBody: true
- username: "front"
- password: "s3cret"
+ - choice:
+ when:
+ # no address: the address of the port in the WSDL, which the
legacy service serves with its own address
+ - simple: "${variable.orderId} == '8'"
+ steps:
+ - to:
+ uri: "kamelet:soap-action"
+ parameters:
+ wsdlURL:
"http://localhost:{{soap.backend.port}}/orders?wsdl"
+ operation: "getOrder"
+ faultAsBody: true
+ username: "front"
+ password: "s3cret"
+ otherwise:
+ steps:
+ - to:
+ uri: "kamelet:soap-action"
+ parameters:
+ address: "http://localhost:{{soap.backend.port}}/orders"
+ wsdlURL: "classpath:orders.wsdl"
+ operation: "getOrder"
+ faultAsBody: true
+ username: "front"
+ password: "s3cret"
- log: "Front got SoapFault=${header.SoapFault}
SoapFaultCode=${header.SoapFaultCode}: ${body}"
- choice:
when:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-soap12.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-soap12.citrus.it.yaml
index 166b5cb91..a64937355 100644
---
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-soap12.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-soap12.citrus.it.yaml
@@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------
name: soap-soap12-test
-description: 'soap-source serves a WSDL with a SOAP 1.2 binding: a reply and a
declared fault, both in SOAP 1.2'
+description: 'soap-source serves a WSDL with a SOAP 1.2 binding: a reply, a
declared fault and a fault the route builds as text, all in SOAP 1.2'
actions:
- camel:
cli:
@@ -64,3 +64,21 @@ actions:
type: "plaintext"
body:
data:
'@contains(''env:Sender</soap:Value></soap:Code><soap:Reason><soap:Text
xml:lang="en">Order 404 not
found</soap:Text></soap:Reason><soap:Detail><orderNotFound
xmlns="http://example.com/orders"><orderId>404</orderId></orderNotFound></soap:Detail>'')@'
+
+ # A SOAP 1.2 fault the route builds as XML text
+ - http:
+ client: "http://localhost:${soap.soap12.port}"
+ sendRequest:
+ POST:
+ path: "/orders"
+ contentType: "application/soap+xml"
+ body:
+ data: '<env:Envelope
xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><o:getOrder
xmlns:o="http://example.com/orders"><o:orderId>409</o:orderId></o:getOrder></env:Body></env:Envelope>'
+ - http:
+ client: "http://localhost:${soap.soap12.port}"
+ receiveResponse:
+ response:
+ status: 500
+ type: "plaintext"
+ body:
+ data:
'@contains(''env:Sender</soap:Value></soap:Code><soap:Reason><soap:Text
xml:lang="en">Order 409 is locked</soap:Text></soap:Reason>'')@'
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-wssec-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-wssec-route.yaml
new file mode 100644
index 000000000..bb6b24179
--- /dev/null
+++ b/tests/camel-kamelets-itest/src/test/resources/soap/soap-wssec-route.yaml
@@ -0,0 +1,101 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+# The service of orders.wsdl, served by soap-source for the user alice only (a
WS-Security UsernameToken), and calls
+# of it with soap-action: the right password as text and as a digest, and a
wrong password
+- route:
+ id: "orders-wssec"
+ from:
+ uri: "kamelet:soap-source"
+ parameters:
+ address: "http://0.0.0.0:{{soap.wssec.port}}/orders"
+ wsdlURL: "classpath:orders.wsdl"
+ wsSecurityUsername: "alice"
+ wsSecurityPassword: "s3cr&t+pw"
+ steps:
+ - log: "Service ${header.CamelCxfOperationName}
user=${header.CamelAuthentication}"
+ - setBody:
+ simple: '<getOrderResponse
xmlns="http://example.com/orders"><order><orderId>${xpath(/*/*[local-name()=''orderId'']/text())}</orderId><customer>ACME</customer><status>NEW</status><item><sku>A-1</sku><quantity>1</quantity><price>1.00</price></item></order></getOrderResponse>'
+# the same service for alice, which requires a PasswordDigest
+- route:
+ id: "orders-wssec-digest"
+ from:
+ uri: "kamelet:soap-source"
+ parameters:
+ address: "http://0.0.0.0:{{soap.wssec.port}}/orders-digest"
+ wsdlURL: "classpath:orders.wsdl"
+ wsSecurityUsername: "alice"
+ wsSecurityPassword: "s3cr&t+pw"
+ wsSecurityPasswordType: "Digest"
+ steps:
+ - log: "Digest service ${header.CamelCxfOperationName}
user=${header.CamelAuthentication}"
+ - setBody:
+ simple: '<getOrderResponse
xmlns="http://example.com/orders"><order><orderId>${xpath(/*/*[local-name()=''orderId'']/text())}</orderId><customer>ACME</customer><status>NEW</status><item><sku>A-1</sku><quantity>1</quantity><price>1.00</price></item></order></getOrderResponse>'
+- route:
+ from:
+ uri: "timer:wssec"
+ parameters:
+ repeatCount: 1
+ delay: 2000
+ steps:
+ - setBody:
+ constant: '<getOrder
xmlns="http://example.com/orders"><orderId>21</orderId></getOrder>'
+ - to:
+ uri: "kamelet:soap-action"
+ parameters:
+ address: "http://localhost:{{soap.wssec.port}}/orders"
+ wsdlURL: "classpath:orders.wsdl"
+ operation: "getOrder"
+ wsSecurityUsername: "alice"
+ wsSecurityPassword: "s3cr&t+pw"
+ - log: "Text password: ${body}"
+ - setBody:
+ constant: '<getOrder
xmlns="http://example.com/orders"><orderId>22</orderId></getOrder>'
+ - to:
+ uri: "kamelet:soap-action"
+ parameters:
+ address: "http://localhost:{{soap.wssec.port}}/orders-digest"
+ wsdlURL: "classpath:orders.wsdl"
+ operation: "getOrder"
+ wsSecurityUsername: "alice"
+ wsSecurityPassword: "s3cr&t+pw"
+ wsSecurityPasswordType: "Digest"
+ - log: "Digest password: ${body}"
+ - setBody:
+ constant: '<getOrder
xmlns="http://example.com/orders"><orderId>25</orderId></getOrder>'
+ - to:
+ uri: "kamelet:soap-action"
+ parameters:
+ address: "http://localhost:{{soap.wssec.port}}/orders-digest"
+ wsdlURL: "classpath:orders.wsdl"
+ operation: "getOrder"
+ wsSecurityUsername: "alice"
+ wsSecurityPassword: "s3cr&t+pw"
+ faultAsBody: true
+ - log: "Text to digest service: SoapFault=${header.SoapFault}"
+ - setBody:
+ constant: '<getOrder
xmlns="http://example.com/orders"><orderId>23</orderId></getOrder>'
+ - to:
+ uri: "kamelet:soap-action"
+ parameters:
+ address: "http://localhost:{{soap.wssec.port}}/orders"
+ wsdlURL: "classpath:orders.wsdl"
+ operation: "getOrder"
+ wsSecurityUsername: "alice"
+ wsSecurityPassword: "wrong"
+ faultAsBody: true
+ - log: "Wrong password: SoapFault=${header.SoapFault}
SoapFaultCode=${header.SoapFaultCode}"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap-wssec.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-wssec.citrus.it.yaml
new file mode 100644
index 000000000..96034a82f
--- /dev/null
+++
b/tests/camel-kamelets-itest/src/test/resources/soap/soap-wssec.citrus.it.yaml
@@ -0,0 +1,79 @@
+# ---------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ---------------------------------------------------------------------------
+
+name: soap-wssec-test
+description: 'soap-source requires a WS-Security UsernameToken of its user,
and soap-action sends one: the right password as text and as a digest passes; a
wrong password, the other password type and a request without a token get a
SOAP fault'
+actions:
+ # The options need the jar cxf-rt-ws-security of the CXF version of Camel
+ - camel:
+ cli:
+ run:
+ args:
+ - "--dep=mvn:org.apache.cxf:cxf-rt-ws-security:4.2.4"
+ resources:
+ - "orders.wsdl"
+ integration:
+ file: "soap/soap-wssec-route.yaml"
+ systemProperties:
+ properties:
+ - name: "soap.wssec.port"
+ value: "${soap.wssec.port}"
+
+ - camel:
+ cli:
+ verify:
+ integration: "soap-wssec-route"
+ logMessage: "<order><orderId>21</orderId><customer>ACME</customer>"
+ - camel:
+ cli:
+ verify:
+ integration: "soap-wssec-route"
+ logMessage: "Service getOrder user=Subject:"
+ - camel:
+ cli:
+ verify:
+ integration: "soap-wssec-route"
+ logMessage: "<order><orderId>22</orderId><customer>ACME</customer>"
+ - camel:
+ cli:
+ verify:
+ integration: "soap-wssec-route"
+ logMessage: "Wrong password: SoapFault=A security error was
encountered when verifying the message SoapFaultCode="
+ # a service that requires a PasswordDigest refuses a PasswordText
+ - camel:
+ cli:
+ verify:
+ integration: "soap-wssec-route"
+ logMessage: "Text to digest service: SoapFault=A security error was
encountered when verifying the message"
+
+ # A request without a UsernameToken is refused before the route sees it
+ - http:
+ client: "http://localhost:${soap.wssec.port}"
+ sendRequest:
+ POST:
+ path: "/orders"
+ contentType: "text/xml"
+ body:
+ data: '<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><o:getOrder
xmlns:o="http://example.com/orders"><o:orderId>24</o:orderId></o:getOrder></soap:Body></soap:Envelope>'
+ - http:
+ client: "http://localhost:${soap.wssec.port}"
+ receiveResponse:
+ response:
+ status: 500
+ type: "plaintext"
+ body:
+ data: '@contains(''<soap:Fault>'')@'
diff --git
a/tests/camel-kamelets-itest/src/test/resources/soap/soap12-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/soap/soap12-route.yaml
index e5757b0a9..cedb62eda 100644
--- a/tests/camel-kamelets-itest/src/test/resources/soap/soap12-route.yaml
+++ b/tests/camel-kamelets-itest/src/test/resources/soap/soap12-route.yaml
@@ -37,6 +37,11 @@
constant: "Client"
- setBody:
constant: '<orderNotFound
xmlns="http://example.com/orders"><orderId>404</orderId></orderNotFound>'
+ # the route builds the SOAP 1.2 fault itself, as XML text
+ - simple: "${body} contains '>409<'"
+ steps:
+ - setBody:
+ constant: '<env:Fault
xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Code><env:Value>env:Sender</env:Value></env:Code><env:Reason><env:Text
xml:lang="en">Order 409 is locked</env:Text></env:Reason></env:Fault>'
otherwise:
steps:
- setBody: