Search code examples
jax-wscxfcxfrs

CXF RS and JAX-WS encoded content unreadable


My Issue is 2-fold and it has to do with the encoding. I have a REST web application deployed on JBoss 7.1.1. This has adapters to an external web service for which I have created stubs with CXF java2wsdl from the provided WSDLs. During the request/responses to this external web service requests & responses can contain Bulgarian encoded content.

The issue is that this encoded content is not correctly sent/consumed by my REST services nor by my SOAP adapters whilst it is from SOAPUI. Below is an example

REST CALL passes the parameter "Тест Тест" as

@PathParam("receiverName") String receiverName

The Header contains charset=UTF-8

Server Log using the cxf logging interceptor logs the following

--------------------------------------
 Inbound Message
----------------------------
ID: 32
Address:     http://127.0.0.1:8080/rest/request/card/10122083/%D0%A2%D0%B5%D1%81%D1%82%20%D0%A2%D0%B5%D1%81%D1%82/1234124143312
Encoding: UTF-8
Http-Method: POST
Content-Type: application/json; charset=UTF-8
    Headers: {Accept=[application/json], accept-encoding=[gzip, deflate], accept-language=    [en-gb,en;q=0.5], cache-control=[no-cache], connection=[keep-alive], Content-Length=[313],     content-type=[application/json; charset=UTF-8], host=[127.0.0.1:8080], pragma=[no-cache],     user-agent=[Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1]}
----------------------------

The parameter now printed in a log by my code has the value "???? ????"

On the backend when I receive content in bulgarian again I have the issue, below is the example of such a response

Encoding: UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], 

The request was sent with Headers above according to the log and wireshark and the response is:

-----------------------------------------------------------------
ID: 2
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: text/xml
Headers: {Content-Length=[1011], content-type=[text/xml], Server=[IRS/1.0.18.0 guz]}
Payload: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:loy="http://www.location.bg/Loyalty/">
<soapenv:Header/>
<soapenv:Body>
<loy:CustLoyaltyResponse>
                <OutputRequestID>SCR0000000394</OutputRequestID>
                <OutputTimeStamp>20120918095649992</OutputTimeStamp>
                <StatusCode>0</StatusCode>
                <StatusMessage>Loyal Customer</StatusMessage>
                <CustomerCode>10122083</CustomerCode>
                <CustomerLoyalStatus>1</CustomerLoyalStatus>
                <LoyalLevel>Special</LoyalLevel>
                <CardObject>
                                <CardStatus>0</CardStatus>
                                <CardCustCode>10122083</CardCustCode>
                                <CardNo>100012624110122083</CardNo>
                                <CardState>4</CardState>
                                <Level>Special</Level>
                                <City>Р?Р°С?РЅР°</City>
                                <Postcode>9000</Postcode>
                                <Address>жк. Чайка</Address>
                                <NameOfRecipient>РўРµС?С? РўРµС?С?</NameOfRecipient>
                                <NumberOfRecipient>12345678</NumberOfRecipient>
                                <LastStatusChangeDate></LastStatusChangeDate>
                </CardObject>
</loy:CustLoyaltyResponse>
</soapenv:Body>
</soapenv:Envelope>
-----------------------------------------------------------------

The issue can be seen in the

                                <City>Р?Р°С?РЅР°</City>
                            <Address>жк. Чайка</Address>

whilst in SOAPUI the result is correct

<City>Варна</City>
<Address>жк. Чайка</Address>

Any thoughts what the problem is and how to solve it?


Solution

  • Might it be that the logging facilities are not recording output as UTF-8? If you are using log4j, try adding

    <param name="Encoding" value="UTF-8"/>
    

    to its configuration.