我的問題是雙重的,它與編碼有關。我在JBoss 7.1.1上部署了一個REST Web應用程序。它具有適配器,可以連接到外部Web服務,爲此,我使用提供的WSDL創建了CXF java2wsdl的存根。在請求/響應此外部網絡服務請求&響應可以包含保加利亞編碼的內容。CXF RS和JAX-WS編碼的內容不可讀
問題是,我的REST服務和SOAP適配器不能正確地發送/使用此編碼的內容。下面是一個例子
REST CALL傳遞參數「ТестТест」作爲
@PathParam( 「receiverName」)字符串receiverName
包頭包含的charset = UTF-8
使用cxf日誌攔截器的服務器日誌記錄以下日誌
--------------------------------------
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]}
----------------------------
現在通過我的代碼打印在日誌中的參數具有值「???? ????」
在後端,當我在保加利亞接收內容再次我有問題,以下是這樣
Encoding: UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*],
該請求用集管根據上述發送的響應的示例日誌和Wireshark和反應是:
-----------------------------------------------------------------
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>
-----------------------------------------------------------------
問題可以在
<City>Р?Р°С?РЅР°</City>
<Address>жк. Чайка</Address>
可見
而在SOAPUI的結果是正確的
<City>Варна</City>
<Address>жк. Чайка</Address>
任何想法是什麼問題,如何解決呢?
最後,我創建了一個嘲笑外部Web服務的Web服務,並且我返回了服務處理完整的保加利亞字符。這是由於在標題屬性Content-Type和Encoding處設置了正確的設置,它使用以下值設置: ** Content-Type:text/xml; charset = UTF-8' 編碼:UTF-8 ** 從外部Web服務返回的標頭爲 **內容類型:text/xml 編碼:ISO-8859-1 ** –