请教大家一个cxf的编码问题

View: New views
2 Messages — Rating Filter:   Alert me  

请教大家一个cxf的编码问题

by elminstre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

我自己用cxf实现了一个demo ,wsdl出于其它服务生成的,client和server均由cxf的wsdl2java生成,启动server
和client,通信正常,但从client日志来看,截获的soap包,为什么没有xml的头呢?即
<?xml version="1.0" encoding="UTF-8"?>这一行,而且client的Content-Type:为什么没有
charset=utf-8,而在server端传来的soap确有,请教大家,相信大家也应该遇到过这个问题吧?
(补充:截获gsoap发的soap包就有xml头和chartset,因为与gsoap传输中文存在乱码,所以怀疑是不是cxf的编码问题)

这里是client发出的soap
信息: Outbound Message
---------------------------
ID: 1
Address: http://localhost:8080/WSserver/services/BookService
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=[""], Accept=[*/*]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/"><soap:Body><getAllBook xmlns="http://service"
xmlns:ns2="http://entity"/></soap:Body></soap:Envelope>
--------------------------------------
2009-10-28 23:13:47 org.apache.cxf.interceptor.LoggingInInterceptor
logging

这里是client接受到server的soap
信息: Inbound Message
----------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Content-Length=
[274], Server=[Jetty(6.1.18)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/"><soap:Body><getAllBookResponse xmlns="http://service"
xmlns:ns2="http://entity"><out xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance" xsi:nil="true"/></getAllBookResponse></soap:Body></
soap:Envelope>
--------------------------------------
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
 要在此论坛发帖,请发电子邮件到 cxf-zh@...
 要退订此论坛,请发邮件至 cxf-zh-unsubscribe@...
 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
----
Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
-~----------~----~----~----~------~----~------~--~---


Re: 请教大家一个cxf的编码问题

by 江鸟飞 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

请教下,cxf 的eclipse 插件,麻烦分享下您的环境搭建.我是eclise3.5.cxf 是2.1. thx

                                 

2009/10/28 elminstre <elminstre@...>
我自己用cxf实现了一个demo ,wsdl出于其它服务生成的,client和server均由cxf的wsdl2java生成,启动server
和client,通信正常,但从client日志来看,截获的soap包,为什么没有xml的头呢?即
<?xml version="1.0" encoding="UTF-8"?>这一行,而且client的Content-Type:为什么没有
charset=utf-8,而在server端传来的soap确有,请教大家,相信大家也应该遇到过这个问题吧?
(补充:截获gsoap发的soap包就有xml头和chartset,因为与gsoap传输中文存在乱码,所以怀疑是不是cxf的编码问题)

这里是client发出的soap
信息: Outbound Message
---------------------------
ID: 1
Address: http://localhost:8080/WSserver/services/BookService
Encoding: UTF-8
Content-Type: text/xml
Headers: {SOAPAction=[""], Accept=[*/*]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/
"><soap:Body><getAllBook xmlns="http://service"
xmlns:ns2="http://entity"/></soap:Body></soap:Envelope>
--------------------------------------
2009-10-28 23:13:47 org.apache.cxf.interceptor.LoggingInInterceptor
logging

这里是client接受到server的soap
信息: Inbound Message
----------------------------
ID: 1
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {content-type=[text/xml; charset=utf-8], Content-Length=
[274], Server=[Jetty(6.1.18)]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/
envelope/
"><soap:Body><getAllBookResponse xmlns="http://service"
xmlns:ns2="http://entity"><out xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance
" xsi:nil="true"/></getAllBookResponse></soap:Body></
soap:Envelope>
--------------------------------------



--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛“cxf-zh”论坛。
 要在此论坛发帖,请发电子邮件到 cxf-zh@...
 要退订此论坛,请发邮件至 cxf-zh-unsubscribe@...
 更多选项,请通过 http://groups.google.com/group/cxf-zh?hl=zh-CN 访问该论坛
----
Apache CXF 首页 http://cwiki.apache.org/confluence/display/CXF/Index
-~----------~----~----~----~------~----~------~--~---