Thanks. My route is a little bit different and I don't want to write the
request "by hand" like that. What I'm doing is:

  process(populateBeanProcessor). // 1
  marshal(soapJaxbDataFormat). // 2
  to(fooService). // 3
  etc()

1 = processor creates a JAXB bean which represents my request
2 = JAXB bean is converted into SOAP XML message
3 = we call web service

I ended up writing a CXF interceptor for setting the http header:

public class Utf8SoapRequestInterceptor extends
AbstractPhaseInterceptor<Message> {
    public Utf8SoapRequestInterceptor() {
        super(Phase.MARSHAL);
    }
    @Override
    public void handleMessage(Message message) throws Fault {
        Map<String, List> headers = (Map<String, List>)
message.get(Message.PROTOCOL_HEADERS);
        try {
            headers.put("Content-Type",
Collections.singletonList(message.get("application/soap+xml;charset=UTF8")));
        } catch (Exception ce) {
            throw new Fault(ce);
        }
    }
}

<camelcxf:cxfEndpoint id="fooService"
                      address="${bla.cxf}"
                      serviceClass="bla._1_0.UraPort">
    <camelcxf:outInterceptors>
        <bean class="bla.Utf8SoapRequestInterceptor" />
    </camelcxf:outInterceptors>
    <camelcxf:properties>
        <entry key="dataFormat" value="MESSAGE"/>
        <entry key="loggingFeatureEnabled" value="true"/>
    </camelcxf:properties>
</camelcxf:cxfEndpoint>

This works and I get the response in UTF-8.

I would be interested if the same was possible somehow declaratively,
without writing code?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Trying-to-consume-SOAP-WS-with-UTF-8-content-getting-Invalid-UTF-8-middle-byte-0x3c-tp5745394p5745427.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to