Apache Camel does not properly handle non-ASCII character in SOAP request

I am making a request against Apache Camel. It is used as a pass for WS.

Inquiry:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="...">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:AddCompanyRequest>
         <urn:Company>
            <urn:Name>Ascii test Β’Β’</urn:Name>
         </urn:Company>
      </urn:AddCompanyRequest>
   </soapenv:Body>
</soapenv:Envelope>

Unfortunately, non-ASCII characters are displayed as "?" in the facade of WS.

WS appearance:

@Path("/company")
public interface CompanyFacade {

    @POST
    @Consumes("text/xml") // Already tried "text/xml; charset=utf-8"
    @Produces("text/xml")
    JAXBElement<StandardResponseType> add(AddCompanyRequestType addCompanyRequestType);

}

Camel configuration:

<cxf:cxfEndpoint id="companyEndpoint" address="/company"
    wsdlURL="service.wsdl"
    loggingFeatureEnabled="false">
    <cxf:properties>
        <entry key="dataFormat" value="PAYLOAD" />
    </cxf:properties>
    <cxf:outInterceptors>
        <bean class="org.apache.camel.component.cxf.WriteXmlDeclarationInterceptor" />
    </cxf:outInterceptors>
</cxf:cxfEndpoint>
(...)
<route>
    <from uri="cxf:bean:companyEndpoint" />
    <policy ref="customProvider">
        <to
            uri="validator:service.xsd?useDom=true" />
        <choice>
            <when>
                <simple>${in.header.operationName} contains 'remove'</simple>
                <setHeader headerName="restSlip">
                    <constant>removeCompanyURL</constant>
                </setHeader>
            </when>
            <otherwise>
                <setHeader headerName="restSlip">
                    <constant>companyURL</constant>
                </setHeader>
            </otherwise>
        </choice>
        <to uri="direct:dispatcher" />
    </policy>
</route>

I tried to debug Camel by adding an interceptor at different stages (RECEIVE, POST_MARSHAL, PRE_INVOKE), but the characters are always displayed correctly.

In addition, I checked the encoding / mime -type / charset everywhere and everything looks as expected.

Does anyone know why it is still failing and what can I do to fix it?

Note. I am using Camel v2.12.2 and Spring v3.2.4.RELEASE in this project.

+4

Source: https://habr.com/ru/post/1677466/


All Articles