Cameleer

Spring Web Services component

The spring-ws component hosts and calls payload-oriented SOAP web services: consumers are selected by the payload root element, SOAP action, XPath or WS-Addressing, and the body is the payload XML.

Scheme: spring-ws: · Crate: cameleer-soap · Cargo feature: soap · Consumer: yes · Producer: yes · Apache Camel: Spring Web Services

No Spring is involved: the scheme reproduces camel-spring-ws on Cameleer's HTTP server. Unlike cxf, there is no WSDL and no parameter mapping; routes work with the XML payload.

When to use it

  • Host a contract-first SOAP service where the route builds the XML response itself.
  • Route different SOAP requests arriving at one address to different routes by root element or SOAP action.
  • Send a payload to a SOAP service and get the response payload back.

URI format

text
spring-ws:rootqname:{namespace}localName[?options]      (consumer)
spring-ws:soapaction:action[?options]                   (consumer)
spring-ws:uri:http://host:port/path                     (consumer: every request to the address)
spring-ws:xpathresult:value?expression=xpath[&options]  (consumer)
spring-ws:action:wsaAction / spring-ws:to:wsaTo         (consumer, WS-Addressing)
spring-ws:beanname:mappingBean                          (consumer)
spring-ws:http://host:port/path[?options]               (producer)

Consumers listen on address (default /ws on the platform HTTP port). All consumers on one address share a dispatcher; a request that matches none gets 404.

Example

An order status service. Requests whose payload root is {urn:orders}GetOrderStatus reach this route; the order id is read with XPath and the response payload is built with Simple.

yaml example: spring-ws-order-status
- route:
    id: order-status
    from:
      uri: "spring-ws:rootqname:{urn:orders}GetOrderStatus?address=http://0.0.0.0:{{env:SOAP_PORT:8088}}/ws"
      steps:
        - setHeader:
            name: orderId
            xpath: "//*[local-name()='id']/text()"
        - setBody:
            simple: '<GetOrderStatusResponse xmlns="urn:orders"><id>${header.orderId}</id><status>shipped</status></GetOrderStatusResponse>'

A client sends <GetOrderStatus xmlns="urn:orders"><id>42</id></GetOrderStatus> with spring-ws:http://host:8088/ws and gets the response payload back.

Rust DSL

rust
fn order_status_route(b: &mut RouteBuilder, port: u16) {
    b.from(&format!("spring-ws:rootqname:{{urn:orders}}GetOrderStatus?address=http://0.0.0.0:{}/ws", port))
        .route_id("order-status")
        .set_header("orderId", xpath("//*[local-name()='id']/text()"))
        .set_body(simple(r#"<GetOrderStatusResponse xmlns="urn:orders"><id>${header.orderId}</id><status>shipped</status></GetOrderStatusResponse>"#));
}

Options

optiondefaultdescription
address/ws on the platform portConsumer: http(s)://host:port/path or a path.
expressionxpathresult: XPath evaluated on the payload.
namespacesNamespace prefixes for expression.
soapActionProducer: SOAP action.
wsAddressingActionProducer: WS-Addressing Action.
soapVersion1.1Producer: 1.1 or 1.2.
timeoutProducer: timeout in ms.
username, passwordProducer: basic authentication.
sslContextParameters#bean for https.
wsSecurityUsername, ...The WS-Security options of cxf.

Spring message factories and interceptors are accepted and ignored. SOAP attachments are not supported.

Message headers

headerdirectiondescription
CamelSpringWebserviceSoapActionout / inSOAP action of the request; producer: overrides soapAction.
CamelSpringWebserviceSoapHeaderout / inSOAP header blocks.
CamelSpringWebserviceAddressingActionout / inWS-Addressing action.
CamelSpringWebserviceEndpointUriinProducer: overrides the target address.

A null reply body answers 202; an exception becomes a SOAP fault. On the producer, a fault fails the exchange with SoapFaultClientException.

Run it with Docker

sh
docker run --rm -p 8088:8088 -v "$PWD:/routes:ro" pmsudhi/cameleer run /routes/order-status.camel.yaml
curl -XPOST -H 'Content-Type: text/xml' localhost:8088/ws -d \
  '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetOrderStatus xmlns="urn:orders"><id>42</id></GetOrderStatus></s:Body></s:Envelope>'

Common questions

How is this different from cxf?

cxf maps typed parameters from a WSDL; spring-ws hands the route the XML payload and sends back whatever XML the route produces.

How do I serve several operations at one address?

Add one route per root element or SOAP action, all with the same address.

How do I return a SOAP fault?

Throw an exception in the route; it becomes a Server (1.1) / Receiver (1.2) fault.

Found a problem?

If something on this page doesn't match what Cameleer does, or you hit a bug while building with it, please help fix it, whether you are a person or a coding agent: open an issue that describes what you saw, then fork the repository, fix it, add or update a test, run cargo test --workspace, and open a pull request. CONTRIBUTING.md explains the ground rules.

Edit this page on GitHub