Kamelet Catalog

soap action SOAP Action

Provided by: "Apache Software Foundation"

Support Level for this Kamelet is: "Preview"

Calls an operation of a SOAP web service described by a WSDL file for each message, and gives back the response.

Use it to call an existing SOAP service from a route, such as an order or customer service of an older system, with XML and without generating Java code from the WSDL. To serve a SOAP service, use soap-source.

Input: the body is the request element of the operation as XML text, such as <getOrder xmlns="http://example.com/orders"><orderId>7</orderId></getOrder>. It is put in the SOAP Body as it is. With bodyFormat json, the body is JSON text with the fields of the request element, such as {"orderId": "7"}: it is written as XML in the order and with the namespaces of the schema, and a field that the schema does not have fails the message, unless ignoreUnknownFields is true.

Output: the body is the content of the SOAP Body of the response as XML text: the response element of the operation, such as <getOrderResponse xmlns="http://example.com/orders">…​</getOrderResponse>. With bodyFormat json, the body is JSON text with the fields of the response element, such as {"order": {"orderId": "7", "item": [{"sku": "A-1", "quantity": 2}]}}: 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 detail of a fault, with faultAsBody, is XML text also then.

Good to know: a SOAP fault from the service fails the message with an org.apache.cxf.binding.soap.SoapFault error, whose message is the text of the fault, so that a route can catch it by its class name. When faultAsBody is true, the message goes on instead: the body is the content of the detail element of the fault as XML text, such as the fault element the WSDL declares (no body when the fault has no detail), the header SoapFault is the text of the fault, and SoapFaultCode its code: Client or Server with SOAP 1.1, Sender or Receiver with SOAP 1.2. A request that the service refuses, for example because it does not match its XML schema, is a SOAP fault too. SOAP 1.1 or 1.2 is used as the WSDL says. To log in with a WS-Security UsernameToken, set wsSecurityUsername and wsSecurityPassword (Camel JBang downloads the jar org.apache.cxf:cxf-rt-ws-security they need, and camel export adds it to the project). A service that refuses the UsernameToken, for example because of a wrong password, answers with a SOAP fault whose code is SecurityError. Headers that start with Camel, and the SOAPAction, Authorization and Proxy-Authorization headers, are removed from the message first, so a message cannot change the address, the operation or the login.

Configuration Options

The following table summarizes the configuration options available for the soap-action Kamelet:

Property Name Description Type Default Example

operation

Operation

Required The name of the operation to call, as the WSDL names it.

string

getOrder

wsdlURL

WSDL Location

Required Where to read the WSDL file of the service from. file: followed by a path, classpath: followed by a resource in the application, or an https:// URL (an http:// URL works too, but the WSDL decides what is called, so it should not travel unprotected), such as the address of the service followed by ?wsdl.

string

https://legacy.example.com/orders?wsdl

address

Address

The URL of the SOAP service. When it is not set, the address that the WSDL gives for the port is called, the location of its soap:address.

string

https://legacy.example.com/orders

bodyFormat

Body Format

The format of the request the Kamelet takes and of the response it gives. xml is the XML of the SOAP Body as text. json is JSON text that the XML schema of the WSDL types, see the description of the Kamelet. The detail of a fault is XML text in both formats.

Enum values:

* xml * json

string

xml

faultAsBody

Fault As Body

Whether a SOAP fault from the service gives a message with the detail of the fault as body and the SoapFault and SoapFaultCode headers, instead of failing the message.

boolean

false

ignoreUnknownFields

Ignore Unknown Fields

Only used when bodyFormat is json. If true, a JSON field of the request, or an XML element or attribute of the response, that the XML schema of the WSDL does not have is left out. If false, it fails the message.

boolean

false

operationNamespace

Operation Namespace

The namespace of the operation. Only needed when the WSDL has two operations of the same name.

string

http://example.com/orders

password

Password

The password for HTTP Basic authentication.

string

portName

Port Name

The port of the service to call, as \{namespace}name. Only needed when the service has more than one port; otherwise the first one is used.

string

{http://example.com/orders}OrderPort

requestElement

Request Element

Only used when bodyFormat is json. The element of the XML schema that the JSON of a request is turned into, as \{namespace}name or as a name that only one element of the schema has. When it is not set, the element named as operation, which is the request element of a document/literal wrapped service.

string

{http://example.com/orders}getOrder

serviceName

Service Name

The service of the WSDL to call, as \{namespace}name. Only needed when the WSDL has more than one service; otherwise the first one is used.

string

{http://example.com/orders}OrderService

username

Username

The user name for HTTP Basic authentication. When it is set, every request carries it, with password.

string

wsSecurityPassword

WS-Security Password

The password of wsSecurityUsername, sent in the UsernameToken.

string

wsSecurityPasswordType

WS-Security Password Type

How the UsernameToken carries the password. Text sends it as it is, so only use it over HTTPS. Digest sends a SHA-1 digest of it, which is no replacement for HTTPS. It must be the type the service requires, or the service refuses the token. When the WSDL has a WS-SecurityPolicy, the policy decides instead. When it is not set, Text.

Enum values:

* Text * Digest

string

Digest

wsSecurityUsername

WS-Security Username

The user name to send in a WS-Security UsernameToken, in the SOAP header of each request, for a service that requires one. It is not the same as username, which is for HTTP Basic authentication. Set wsSecurityPassword too.

string

Dependencies

At runtime, the soap-action Kamelet relies upon the presence of the following dependencies:

  • camel:cxf-soap

  • camel:xpath

  • 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:timer-source"
      parameters:
        period: 10000
        message: 'test'
      steps:
        - to:
            uri: "kamelet:soap-action"
            parameters:
            .
            .
            .
        - to:
            uri: "kamelet:log-sink"

You can now run it directly through the following command

camel run route.yaml