您现在的位置是:首页 > 电脑 > 

CXF RS和JAX

2025-07-17 15:55:31
CXF RS和JAX-WS编码的内容不可读(CXF RS and JAX-WS encoded content unreadable) 我的问题是2倍,它与编码有关。 我在JBoss 7.1.1上部署了一个REST Web应用程序。 这有一个外部Web服务的适配器,我已经从提供的WSDL中使用CXF java2wsdl创建了存根。 在对此外部Web服务的请求/响
CXF RS和JAX-WS编码的内容不可读(CXF RS and JAX-WS encoded content unreadable)

我的问题是2倍,它与编码有关。 我在JBoss 7.1.1上部署了一个REST Web应用程序。 这有一个外部Web服务的适配器,我已经从提供的WSDL中使用CXF java2wsdl创建了存根。 在对此外部Web服务的请求/响应期间,请求和响应可以包含保加利亚语编码内容。

问题是我的REST服务或SOAP适配器都没有正确地发送/使用这些编码内容,而它来自SOAPUI。 以下是一个例子

REST CALL将参数“ТестТест”传递为

@PathParam(“receiverame”)字符串receiverame

标头包含charset = UTF-8

使用cxf日志记录的服务器日志记录以下内容

-------------------------------------- Inbound Message ---------------------------- ID: 2 Address: http://127.0.0.1:8080/rest/request/card/1012208/%D0%A2%D0%B5%D1%81%D1%82%20%D0%A2%D0%B5%D1%81%D1%82/1241241412 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=[1], content-type=[application/json; charset=UTF-8], host=[127.0.0.1:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows T 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1]} ----------------------------

现在由我的代码打印在日志中的参数值为“???? ????”

在后端,当我再次收到保加利亚语内容时,我遇到了问题,下面就是这种回复的例子

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

该请求是根据日志和wireshark通过上面的Headers发送的,响应是:

----------------------------------------------------------------- ID: 2 Respe-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./soap/envelope/" xmlns:loy="http://www.location.bg/Loyalty/"> <soapenv:Header/> <soapenv:Body> <loy:CustLoyaltyRespe> <OutputRequestID>SCR000000094</OutputRequestID> <OutputTimeStamp>20120918095649992</OutputTimeStamp> <StatusCode>0</StatusCode> <StatusMessage>Loyal Customer</StatusMessage> <CustomerCode>1012208</CustomerCode> <CustomerLoyalStatus>1</CustomerLoyalStatus> <LoyalLevel>Special</LoyalLevel> <CardObject> <CardStatus>0</CardStatus> <CardCustCode>1012208</CardCustCode> <Cardo>10001262411012208</Cardo> <CardState>4</CardState> <Level>Special</Level> <City>Р?Р°С?РЅР°</City> <Postcode>9000</Postcode> <Address>Р¶Рє. Чайка</Address> <ameOfRecipient>РўРµС?С? РўРµС?С?</ameOfRecipient> <umberOfRecipient>1245678</umberOfRecipient> <LastStatusChangeDate></LastStatusChangeDate> </CardObject> </loy:CustLoyaltyRespe> </soapenv:Body> </soapenv:Envelope> -----------------------------------------------------------------

这个问题可以从中看到

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

而在SOAPUI中,结果是正确的

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

有什么想法是什么问题以及如何解决它?

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/respes to this external web service requests & respes can contain Bulgarian encoded content.

The issue is that this encoded content is not correctly sent/cumed 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("receiverame") String receiverame

The Header contains charset=UTF-8

Server Log using the cxf logging interceptor logs the following

-------------------------------------- Inbound Message ---------------------------- ID: 2 Address: http://127.0.0.1:8080/rest/request/card/1012208/%D0%A2%D0%B5%D1%81%D1%82%20%D0%A2%D0%B5%D1%81%D1%82/1241241412 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=[1], content-type=[application/json; charset=UTF-8], host=[127.0.0.1:8080], pragma=[no-cache], user-agent=[Mozilla/5.0 (Windows T 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 respe

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

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

----------------------------------------------------------------- ID: 2 Respe-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./soap/envelope/" xmlns:loy="http://www.location.bg/Loyalty/"> <soapenv:Header/> <soapenv:Body> <loy:CustLoyaltyRespe> <OutputRequestID>SCR000000094</OutputRequestID> <OutputTimeStamp>20120918095649992</OutputTimeStamp> <StatusCode>0</StatusCode> <StatusMessage>Loyal Customer</StatusMessage> <CustomerCode>1012208</CustomerCode> <CustomerLoyalStatus>1</CustomerLoyalStatus> <LoyalLevel>Special</LoyalLevel> <CardObject> <CardStatus>0</CardStatus> <CardCustCode>1012208</CardCustCode> <Cardo>10001262411012208</Cardo> <CardState>4</CardState> <Level>Special</Level> <City>Р?Р°С?РЅР°</City> <Postcode>9000</Postcode> <Address>Р¶Рє. Чайка</Address> <ameOfRecipient>РўРµС?С? РўРµС?С?</ameOfRecipient> <umberOfRecipient>1245678</umberOfRecipient> <LastStatusChangeDate></LastStatusChangeDate> </CardObject> </loy:CustLoyaltyRespe> </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?

最满意答案

可能是记录设施没有以UTF-8记录输出? 如果您使用的是log4j ,请尝试添加

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

到它的配置。

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.

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/61872.html

相关标签:无
上传时间: 2023-04-21 00:31:33
留言与评论(共有 11 条评论)
本站网友 网络反腐
28分钟前 发表
Content-Length=[1]
本站网友 宋楚瑜
26分钟前 发表
{Content-Length=[1011]
本站网友 令妃
20分钟前 发表
user-agent=[Mozilla/5.0 (Windows T 6.1; WOW64; rv
本站网友 成都到上海
29分钟前 发表
deflate]
本站网友 迪拜金融危机
9分钟前 发表
deflate]
本站网友 克丽缇娜美容院招聘
20分钟前 发表
8080]
本站网友 冬日娜刘翔
21分钟前 发表
Header/> <soapenv
本站网友 阎焱
6分钟前 发表
8080/rest/request/card/1012208/%D0%A2%D0%B5%D1%81%D1%82%20%D0%A2%D0%B5%D1%81%D1%82/1241241412 Encoding
本站网友 肥厚型心肌病
9分钟前 发表
Envelope> ----------------------------------------------------------------- 这个问题可以从中看到 <City>Р?Р°С?РЅР°</City> <Address>Р¶Рє. Чайка</Address> 而在SOAPUI中
本站网友 牛奶蜂蜜面膜怎么做
8分钟前 发表
accept-encoding=[gzip