davsclaus opened a new pull request, #3341:
URL: https://github.com/apache/camel-kamelets/pull/3341

   Two new Kamelets (support level Preview) that make SOAP web services usable 
from YAML with only a WSDL file. Both use camel-cxf in `PAYLOAD` mode, so no 
Java code is generated from the WSDL (no wsdl2java/JAXB).
   
   ## soap-source
   
   Serves a SOAP web service described by a WSDL, and answers each call with 
the reply of the route. Use it as a SOAP front that keeps existing SOAP clients 
working while the route calls REST services or other systems.
   
   Options:
   - `address` (required): the URL to serve at, such as 
`http://0.0.0.0:8080/orders`.
   - `wsdlURL` (required): `file:`, `classpath:` or `https://`.
   - `serviceName`, `portName`: `{ns}name`, only needed when the WSDL has 
several.
   - `publishedEndpointUrl`: the address the served `?wsdl` gives to clients. 
Without it, CXF uses the client's Host header.
   - `schemaValidation` (default `true`).
   - `loggingEnabled` (default `false`).
   
   - **Output (what the route gets):** the request element of the operation as 
XML text. The headers `CamelCxfOperationName` and `CamelCxfOperationNamespace` 
say which operation was called, and the request's HTTP headers are headers too.
   - **Reply:** the route's body, as XML text, is the content of the SOAP Body 
of the response.
   - **Faults:** the route sets the header `SoapFault` (the fault text) and 
optionally `SoapFaultCode`: `Client`, which is sent as `Sender` with SOAP 1.2, 
or the default `Server`/`Receiver`. The body becomes the fault detail.
     - The fault is built in the SOAP version of the request.
     - A route failure gives the muted fault `Exchange processing failed`, 
which does not say why.
   - **Reply headers:** they are removed before the response, so they are not 
sent back to the client as HTTP headers.
   
   ## soap-action
   
   Calls an operation of a SOAP service described by a WSDL for each message, 
and gives back the response.
   
   Options:
   - `address`, `wsdlURL`, `operation` (all required).
   - `operationNamespace`, `serviceName`, `portName`.
   - `faultAsBody` (default `false`).
   - `username` / `password`: HTTP Basic. The password uses `format: password`, 
and both have the credentials x-descriptor.
   
   - **Input:** the request element as XML text.
   - **Output:** the response element as XML text.
   - **Faults:** a SOAP fault fails the message with 
`org.apache.cxf.binding.soap.SoapFault`. With `faultAsBody`, the body is 
instead the content of the fault's `detail`, with the headers `SoapFault` and 
`SoapFaultCode`. These are exactly what soap-source takes, so a front can pass 
a backend fault on unchanged.
   - **Removed headers:** before the call, the Kamelet removes:
     - every `Camel*` header (`CamelCxfOperationName`, 
`CamelDestinationOverrideUrl`, ...);
     - the former `operationName`/`operationNamespace`, `RequestContext` and 
`ResponseContext`;
     - `SOAPAction`, `Authorization` and `Proxy-Authorization`;
     - relayed `org.apache.cxf.*` headers.
   
   ## Design choices
   
   - **XML only in this PR.** The prototype had a JSON mode: a generic XSLT 
over camel-xj, embedded in the template as a `resource:base64:` URI. It was 
fragile, and without the XSD it is lossy:
     - all values are text;
     - one repeated element is an object, two are an array;
     - JSON must list its fields in XSD order;
     - namespaces must come from options.
   
     The test front shows that JSON in the middle already works with 
`xj-identity-action` (XML2JSON) and an XML reply. A JSON mode will follow once 
Camel can map JSON <-> XML driven by the XSD, as `camel-protobuf` does for 
`.proto` schemas with `schema`/`messageName` (CAMEL-27329). That also keeps 
Saxon (about 6 MB) out of the SOAP Kamelets.
   - **Safe defaults (security model):**
     - Schema validation is on.
     - A DOCTYPE in the request is refused (CXF default, tested).
     - Route errors are muted (camel-cxf `muteException` default).
     - `SoapFault*`, `CamelHttp*` and `CamelCxfMessage` are removed from the 
request.
     - All reply headers are removed before the response.
     - The dispatch headers are removed in soap-action (see above).
   - **WS-Security is left out.** It can't be configured from properties alone: 
the server side needs a Java `CallbackHandler`, and the YAML DSL camelCases 
dashed keys of `properties.*` such as `security.callback-handler`. It is a 
follow-up.
   - **Dependencies:** `camel:cxf-soap` (plus `camel:xpath` for the action). On 
Camel JBang they resolve without `--dep`, and JBang adds the Undertow HTTP 
transport by itself. A user route that catches 
`org.apache.cxf.binding.soap.SoapFault` by class name needs 
`--dep=camel:cxf-soap`; the action's description says so.
   - **Runtimes:** only Camel JBang was tested. On Spring Boot and Quarkus, CXF 
is served by the runtime's servlet and `address` may need to be a relative 
path. `address` is limited to `http(s)://` for now.
   
   ## Tests
   
   New `SoapIT` (package `soap`, ports from `ServerPorts.next()`, no 
containers), with a small Order WSDL in SOAP 1.1 and 1.2 variants:
   - `soap-front-backend-test` runs a legacy service (soap-source) and a SOAP 
front (soap-source, then `xj-identity-action`, then soap-action calling the 
legacy service with hostile headers set). It checks:
     - the reply through the front, which the front has changed;
     - the request as JSON in the front;
     - that the legacy service got the WSDL's SOAPAction and the configured 
Basic login, not the hostile headers;
     - a declared fault passed on with its detail;
     - a fault without detail passed on;
     - the muted fault of a failing route (the exception text does not leak);
     - a DOCTYPE/XXE request refused;
     - `publishedEndpointUrl` in the served WSDL.
   - `soap-soap12-test` checks a SOAP 1.2 reply and a declared fault with the 
`Sender` code, with `serviceName`/`portName` set.
   
   Local results:
   - `./mvnw -o clean install -DskipITs` passes.
   - `./mvnw -o verify -pl tests/camel-kamelets-itest -Dit.test=SoapIT`: 2 
tests, 2 passed. A deliberately wrong expectation made the front test fail, so 
it does check.
   
   Fixes #3335.
   
   ## Upgrade note
   
   New Kamelets `soap-source` and `soap-action` (Preview): serve a SOAP web 
service from a WSDL, with the route's reply as the response and SOAP faults 
from headers, or call an operation of a SOAP service from its WSDL, with XML 
text in and out and no generated Java code.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to