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

   Follows [CAMEL-27375](https://issues.apache.org/jira/browse/CAMEL-27375), 
merged on Camel main for 4.24.0: the new data format `xsdJson` 
(`camel:xsd-json`) maps XML to JSON and back, using an XML Schema.
   
   **Stacked on #3356**, branch `quick-fix/soap-fault-string-address`. Merge 
that one first; this branch then rebases onto main.
   
   ## Changes to soap-source and soap-action
   
   - **New option `bodyFormat`** (`xml`, the default, or `json`), so nothing 
changes for existing users. With `json`:
     - The route gets typed JSON: numbers, `true`/`false`, and an element that 
can repeat is always an array, also with one item.
     - This replaces the advice to use `xj-identity-action`, where every value 
is text and a single element is not an array.
   - **New option `ignoreUnknownFields`**, default false. By default, a field 
or element that the schema does not declare fails the call; with true, it is 
left out.
   - **soap-source:**
     - The request is unmarshalled with `schema: {{wsdlURL}}`. The XML names 
its root element, so no element option is needed.
     - The reply JSON is marshalled to the response element of the operation. 
The element comes from the WSDL: the template sets `CamelXsdJsonElement` from 
the `BindingOperationInfo` exchange property that the CXF consumer sets 
(`operationInfo.output.messageParts[0].elementQName`). So it is the element the 
WSDL output message names, not a guess like `<operation>Response`.
   - **soap-action:**
     - The JSON is marshalled to the request element and the call is made. The 
response is unmarshalled to JSON; its root names the element.
     - There is no operation info before the call, so a new option 
`requestElement` names the request element. When it is not set, it is the 
element named as `operation`, which is the request element of a 
document/literal wrapped service.
     - The template strips `Camel.*` first and sets `CamelXsdJsonElement` 
itself, so a message cannot choose the element.
   - **Faults:** the detail stays XML text in both modes. A fault then passes 
through a JSON facade unchanged: soap-action `faultAsBody`, then soap-source 
with the `SoapFault` headers.
   - **Dependency:** both Kamelets add `camel:xsd-json`.
   
   ## Tests
   
   Local `SoapIT`: **4 tests, 4 passed**.
   
   New `soap-json` test: a SOAP client calls a JSON front (soap-source and 
soap-action with `bodyFormat: json`), which calls a JSON backend (soap-source 
with `bodyFormat: json`). An optional `xs:boolean` `gift` element was added to 
the test WSDL.
   
   - **The request in the middle** is `{"orderId":"7"}`, both at the front and 
at the backend.
   - **Typed values and an array of one item:** the backend replies with its 
fields in another order than the schema. The front gets 
`{"order":{"orderId":"7","customer":"ACME","status":"SHIPPED","item":[{"sku":"A-1","quantity":2,"price":9.95,"gift":true}]}}`.
   - **The SOAP response to the client** has the elements in the order and 
namespace of the schema: `<tns:getOrderResponse 
xmlns:tns="http://example.com/orders";><tns:order><tns:orderId>7</tns:orderId>...<tns:gift>true</tns:gift>...`.
   - **An unknown JSON field** (`color`) fails the soap-action call. With 
`ignoreUnknownFields: true` it is left out, and the call goes through.
   - **The declared fault** passes through the front with its XML detail: HTTP 
500 with `<detail><orderNotFound ...>`.
   
   ## Upgrade note
   
   ```
   * `soap-source` and `soap-action` have a new option `bodyFormat` (`xml` by 
default, or `json`): with `json` the route works with JSON typed by the XML 
schema of the WSDL (numbers, booleans, arrays for repeating elements), using 
the new `camel:xsd-json` data format; also new `ignoreUnknownFields`, and 
`requestElement` on `soap-action`.
   ```
   
   _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