SOAP Source
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Preview"
Serves a SOAP web service described by a WSDL file, and answers each call with the reply of the route.
Use 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.
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. With bodyFormat json, the body is JSON text instead, with the fields of the request element, such as {"orderId": "7"}: each value has the JSON type of its XML schema type, such as a number or true, and an element that can repeat is always an array, also with one item.
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 fault as XML text, such as the fault element the WSDL declares. This is what soap-action gives with faultAsBody, so a fault of a called service can be passed on. The route can also reply with the SOAP fault itself, as XML text, such as <soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soap:Client</faultcode><faultstring>No such order</faultstring></soap:Fault>, or a Fault of SOAP 1.2: the client gets it as a SOAP fault, with its code, text and detail. With bodyFormat json, the reply is JSON text with the fields of the response element of the operation, as the WSDL names it, such as {"order": {"orderId": "7", "item": [{"sku": "A-1", "quantity": 2}]}}: it is written in the order and with the namespaces of the schema, and a field that the schema does not have fails the call, unless ignoreUnknownFields is true. The detail of a fault is XML text also then. When the route fails, the client gets a SOAP fault with the text Exchange processing failed, which does not say why. The headers of the reply are not sent back to the client.
Good to know: the service is served at path on the HTTP server of the integration, under /services (such as http://localhost:8080/services/orders with Camel JBang), and its WSDL at the same URL followed by ?wsdl, with SOAP 1.1 or 1.2 as the WSDL says. The port, TLS and the network interface are the settings of that server (camel.server.*), which REST and health checks share. 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 request (Camel JBang downloads the jar org.apache.cxf:cxf-rt-ws-security they need, and camel export adds it to the project). Protect the URL with your network too. To work with JSON, set bodyFormat to json.
Configuration Options
The following table summarizes the configuration options available for the soap-source Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Path | Required The path to serve the SOAP service at, such as | string | /orders | ||
WSDL Location | Required Where to read the WSDL file from, which describes the operations and their XML schema. | string | classpath:orders.wsdl | ||
Body Format | The format of the request that the route gets and of the reply it gives. Enum values: * xml * json | string | xml | ||
Ignore Unknown Fields | Only used when | boolean | false | ||
Log Messages | Whether to write each SOAP request and response to the log. Do not turn it on when the messages hold personal data or secrets. | boolean | false | ||
Port Name | The port of the service to serve, as | string | {http://example.com/orders}OrderPort | ||
Published URL | The URL that the WSDL served at | string | https://orders.example.com/orders | ||
Schema Validation | Whether to refuse a request, and a reply of the route, that does not match the XML schema of the WSDL. | boolean | true | ||
Service Name | The service of the WSDL to serve, as | string | {http://example.com/orders}OrderService | ||
WS-Security Password | The password of | string | |||
WS-Security Password Type | How the UsernameToken must carry the password. Enum values: * Text * Digest | string | Digest | ||
WS-Security Username | The user that may call the service. When it is set, each request must carry a WS-Security UsernameToken of this user and | string |
Dependencies
At runtime, the soap-source Kamelet relies upon the presence of the following dependencies:
-
camel:cxf-soap
-
camel:kamelet
-
camel:xsd-json
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:soap-source"
parameters:
.
.
.
steps:
- to:
uri: "kamelet:log-sink" You can now run it directly through the following command
camel run route.yaml