Skip to content
Advertisement

Quotation marks in Camel Content-Type header

I am trying to invoke a SOAP service using camel-http4. This service requires me to send the following header: Content-Type: application/soap+xml;charset=UTF-8;action=”ListBerichten”. I have to include the quotation marks, or otherwise the service will return a 400 code

When I try this with a client like Postman or SoapUI or curl it works fine, but when I try it with Camel, it fails to recognize the ‘action’.

(the curl header looks like this) --header 'Content-Type: application/soap+xml;charset=UTF-8;action="ListBerichten"'

I suspect it has something to do with the quotation marks around ListBerichten, but I can’t figure out what it is.

My Camel Route (I’m using a custom http4 implementation for SSL configuration):

        from("direct:d.receive.{{name}}.listberichten").routeId("ReceiveListBerichten")
                .to("xslt:file:{{xslt.cdm.to.target.listberichten}}?saxon=true")
                .setHeader(Exchange.HTTP_METHOD).simple("POST")
                .setHeader("Content-Type").simple("{{soap.contentType.listberichten}}")
                .to("mTlsHttpComponent://{{request.url}}/{{request.url.path}}?useSystemProperties=true&throwExceptionOnFailure=true").id("Receive3")
        ;

and my properties

xslt.cdm.to.target.listberichten=/data/resources/...
soap.contentType.listberichten=application/soap+xml;charset=UTF-8;action="ListBerichten"

request.url=...
request.url.path=...

logging.show.info=showAll=true

And the response I get:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Body>
        <soap:Fault>
            <soap:Code>
                <soap:Value>soap:Sender</soap:Value>
            </soap:Code>
            <soap:Reason>
                <soap:Text xml:lang="nl">Err: Unknown SOAPAction:</soap:Text>
            </soap:Reason>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

I’ve tried escaping the quotes with backslashes, replacing the quotes with UTF-8 encoded characters, setting the header as a String literal and setting the ‘action’ in a separate header but nothing seems to work. How do I need to deal with the quotation marks in the Content-Type header?

Advertisement

Answer

The action parameter is the default way to set the SOAP Action in SOAP version 1.2. The HTTP component parses the content-type values however. Alternative you can use:

  1. netty-http component (since Camel 2.14)
  2. vertx-http component (since Camel 3.5)

Both components don’t parse the header values.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement