davsclaus opened a new pull request, #30614: URL: https://github.com/apache/camel/pull/30614
Fixes CAMEL-27397. `camel generate wsdl` (CAMEL-27376) lists the operations of a WSDL and scaffolds a cxf route, but it did not show what a request looks like. With `--samples` it now writes a sample request, response and faults for each operation (or those of `--operation`). ## camel-xsd-json: `XsdJsonSamples` (commit 1) - New public class `org.apache.camel.dataformat.xsdjson.XsdJsonSamples`. It gives a sample of a global element as JSON, in the form the xsdJson data format reads and writes, and as the XML the data format writes from that JSON. The sample is built from the same schema model, so it is exactly the xsdJson form. The MCP tool of CAMEL-27396 can reuse it. - Values: every element and attribute has a value of its type: the first enumeration value (of the most derived type), a date for `xs:date`, `1` for `xs:int`, `-1` for `xs:negativeInteger`, and so on. A list or repeating element has one item, only the first member of an `xs:choice` is filled in, and a type that contains itself is filled in once. Pattern and length facets are not followed (documented). - The model's `SimpleType` now keeps the built-in type it derives from and its first enumeration value. Only the samples use them. - An optional `XsdJsonSamples.DocumentReader` reads the schema and its imports instead of the CamelContext. The data format itself is unchanged. - Docs: a "Samples" section on the xsdJson page (catalog copy updated). ## camel-jbang: `camel generate wsdl --samples` (commit 2) - Each message is written as XML and as xsdJson JSON. The request is also written in a SOAP envelope of the port's SOAP version, with a `curl` command that posts it to the WSDL address: `SOAPAction` header for SOAP 1.1, `action` in the content type for SOAP 1.2. The user info and query of the address are left out. - Output: printed by default. With `--output=<dir>`, written as files (`getOrder-request.xml`, `.json`, `.soap.xml`, `getOrder-response.*`, `getOrder-fault-orderNotFound.*`), and the curl commands are printed. With `--json`, the samples go into the listing, per operation. `--samples` with `--route`, or with `--json` and `--output`, is a usage error. - The plugin depends on camel-xsd-json. ## Security - A remote WSDL's XML schema is read with the same rules as its `wsdl:import`s (new `WsdlModel.readDocument`): only from the WSDL's host, not from https down to http, and a redirect only to the same scheme, host and port. Without this, the xsd-json loader would follow an `xs:import` to any host on the same scheme. - A SOAP action or address that is not a plain URI (no quote, space or brace) is not put into the curl command; the command is single-quoted. Only NCNames go into file names. Messages that cannot be scaffolded are left out with a warning. ## Tests - `XsdJsonSamplesTest`: every built-in type, enumerations, a list, a choice and a recursive type, in a new `samples.xsd`. The sample XML validates against the XSD, and reads back with the data format as the JSON sample. Also the messages of a WSDL, the shop order, the document reader (it sees the import; refusing it fails the load), and an unknown element. All 48 tests of the module pass. - `CodeWsdlGeneratorTest`: stdout, files, SOAP 1.2 without the user info, JSON, the option rules, a hostile SOAP action left out of the curl line, and a remote WSDL whose schema import on the same host is read, and on another host is refused and never fetched. All 33 tests pass. - End to end: the `placeOrder` sample envelope, posted with its curl line to the scaffolded consumer (`schemaValidationEnabled`) under `camel run`, passes the schema validation. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
