Search code examples
kotlinsoapapache-camelcxf

SOAP version mistmach when sending message to camel endpoint


I had created webservice with camel and cxf. My bean's setting:

@Bean
open fun cxfServlet(): ServletRegistrationBean<CXFServlet> {
    val servlet = ServletRegistrationBean(CXFServlet(), "/ws/*")
    servlet.setLoadOnStartup(1)
    servlet.setName("cxfServlet")
    return servlet
}

@Bean
open fun cxf(): Bus {
    return BusFactory.newInstance().createBus()
}

@Bean("etp")
open fun cxfEndpoint(): CxfEndpoint {
    val endpoint = CxfEndpoint()
    endpoint.beanId = "etp"
    endpoint.address = "/etp"
    endpoint.serviceClass = Product::class.java
    endpoint.wsdlURL = "wsdl/example.wsdl"
    endpoint.dataFormat = DataFormat.POJO
    endpoint.bindingId = SOAPBinding.SOAP12HTTP_BINDING
    return endpoint
}

In route I try to receive a message so:

from("cxf:bean:etp")
    .log(">> etp: start")

But when I send message from soapUI, I get an error:

org.apache.cxf.binding.soap.SoapFault: A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.

But if I set dataFormat value "RAW":

endpoint.dataFormat = DataFormat.RAW

The error disappears. What could be the problem?

I found xml settings for soap binding:

<cxf:binding>
    <soap:soapBinding version="1.2"/>
</cxf:binding>

But where should I set it?


Solution

  • The problem was in the WSDL file. It had namespace:

    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

    But this namespace for soap version 1.1.
    For creating a service with soap 1.2 version should set the namespace:

    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/"