[ 
https://issues.apache.org/jira/browse/CXF-2215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

DingWeilong resolved CXF-2215.
------------------------------

    Resolution: Fixed

I've resovled my problem.
In my Web project, there is Struts2 configuration in web.xml as a filter

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
        http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>

        <listener>
                <listener-class>
                        org.springframework.web.context.ContextLoaderListener
                </listener-class>
        </listener>

        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>
                        
bean.xml,WEB-INF/classes/Struts2_context.xml,WEB-INF/classes/dwr_context.xml,WEB-INF/classes/services.xml</param-value>
        </context-param>


        
        <!-- Strurts2 配置 -->
        <filter>
                <filter-name>struts2</filter-name>
                <filter-class>
                        org.apache.struts2.dispatcher.FilterDispatcher
                </filter-class>
        </filter>

        <filter-mapping>
                <filter-name>struts2</filter-name>
                <url-pattern>/*</url-pattern>
        </filter-mapping>


        <!-- DWR 配置 -->
        <servlet>
                <servlet-name>dwr</servlet-name>
                <servlet-class>
                        org.directwebremoting.spring.DwrSpringServlet
                </servlet-class>
                <init-param>
                        <param-name>debug</param-name>
                        <param-value>true</param-value>
                </init-param>
                <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
                <servlet-name>dwr</servlet-name>
                <url-pattern>/dwr/*</url-pattern>
        </servlet-mapping>
        
        
        <!-- CXF 配置 -->
        <servlet>
                <servlet-name>CXFServlet</servlet-name>
                <servlet-class>
                        org.apache.cxf.transport.servlet.CXFServlet
                </servlet-class>
        </servlet>

        <servlet-mapping>
                <servlet-name>CXFServlet</servlet-name>
                <url-pattern>/services/*</url-pattern>
        </servlet-mapping>


</web-app>

and there is a struts.properties config file, where I write in one line as 
follow:
struts.i18n.encoding=GB2312
I refer some articles about about struts.i18n.encoding, 
find that this property set the CharacterEncoding of request AND response.

So my the problem is clear now. I should do some modifications about my struts 
config file. And I did, so it works!

By the way, if the struts.i18n.encoding property is not set in the struts.xml, 
the default encoding will be the JVM encoding( for example , GBK in my 
environement ), but only UTF-8 can work well in unmarshall process by CXF. I 
think we should be attentive when we use non-English character in parameters of 
CXF Web Service.


In addition, THANK you ALL for your paient answers in time. I appreciate so 
much all the work in this active community!



> can't use  non-English character parameter, soap encoding are not consistent
> ----------------------------------------------------------------------------
>
>                 Key: CXF-2215
>                 URL: https://issues.apache.org/jira/browse/CXF-2215
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 2.2
>         Environment: windows xp, tomcat 6.0.18
>            Reporter: DingWeilong
>            Priority: Critical
>
> I have use cxf 2.2 to publish a web service in tomcat 6, the only operation 
> in which is 
> public java.lang.String greetMe( String name);
> when invoke with a parameter in Chinese value, i couldn't get my result. 
> I use log interceptor to get the log below, you see the encoding and the 
> charset is not consistent
> I track the source code, and see the error when unmarshall invoked.
> you can see the inbound message is parsed allright, but the outbound message 
> is not, error  occurs.
> I have test there're no problem when i use English parameter.
> who can tell me the reason and fix the problem, thanks!
> Inbound Message 
> ---------------------------- 
> Encoding: GB2312 
> Content-Type: text/xml; charset=UTF-8 
> Headers: {cache-control=[no-cache], content-type=[text/xml; 
> charset=UTF-8], connection=[keep-alive], host=[10.61.0.90:8080], 
> content-length=[182], SOAPAction=[""], user-agent=[Apache CXF 2.2], 
> Accept=[*/*], pragma=[no-cache]} 
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/ 
> envelope/"> <soap:Body> <ns2:greetMe xmlns:ns2="http://cxf/";> <arg0>测试 </ 
> arg0> </ns2:greetMe> </soap:Body> </soap:Envelope> 
> Outbound Message 
> --------------------------- 
> Encoding: GB2312 
> Content-Type: text/xml 
> Headers: {} 
> Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/ 
> envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client </ 
> faultcode> <faultstring>Unmarshalling Error: Unexpected close tag &lt;/ 
> ns2:greetMe>; expected &lt;/arg0>.&#xd; 
> at [row,col {unknown-source}]: [1,148] </faultstring> </soap:Fault> </ 
> soap:Body> </soap:Envelope> 
> and the exception is below:
> Interceptor has thrown exception, unwinding now 
> org.apache.cxf.interceptor.Fault: Unmarshalling Error: Unexpected 
> close tag </ns2:greetMe>; expected </arg0>. 
> at [row,col {unknown-source}]: [1,148] 
>         at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall 
> (JAXBEncoderDecoder.java:622) 
>         at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall 
> (JAXBEncoderDecoder.java:527) 
>         at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java: 
> 108) 
>         at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage 
> (DocLiteralInInterceptor.java:102) 
>         at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept 
> (PhaseInterceptorChain.java:236) 
>         at org.apache.cxf.transport.ChainInitiationObserver.onMessage 
> (ChainInitiationObserver.java:89) 
>         at org.apache.cxf.transport.servlet.ServletDestination.invoke 
> (ServletDestination.java:99) 
>         at 
> org.apache.cxf.transport.servlet.ServletController.invokeDestination 
> (ServletController.java:337) 
>         at org.apache.cxf.transport.servlet.ServletController.invoke 
> (ServletController.java:182) 
>         at org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke 
> (AbstractCXFServlet.java:163) 
>         at org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost 
> (AbstractCXFServlet.java:141) 
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) 
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
> (ApplicationFilterChain.java:269) 
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter 
> (ApplicationFilterChain.java:188) 
>         at org.apache.struts2.dispatcher.FilterDispatcher.doFilter 
> (FilterDispatcher.java:413) 
>         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter 
> (ApplicationFilterChain.java:215) 
>         at org.apache.catalina.core.ApplicationFilterChain.doFilter 
> (ApplicationFilterChain.java:188) 
>         at org.apache.catalina.core.StandardWrapperValve.invoke 
> (StandardWrapperValve.java:210) 
>         at org.apache.catalina.core.StandardContextValve.invoke 
> (StandardContextValve.java:174) 
>         at org.apache.catalina.core.StandardHostValve.invoke 
> (StandardHostValve.java:127) 
>         at org.apache.catalina.valves.ErrorReportValve.invoke 
> (ErrorReportValve.java:117) 
>         at org.apache.catalina.core.StandardEngineValve.invoke 
> (StandardEngineValve.java:108) 
>         at org.apache.catalina.connector.CoyoteAdapter.service 
> (CoyoteAdapter.java:151) 
>         at org.apache.coyote.http11.Http11Processor.process 
> (Http11Processor.java:870) 
>         at org.apache.coyote.http11.Http11BaseProtocol 
> $Http11ConnectionHandler.processConnection(Http11BaseProtocol.java: 
> 665) 
>         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket 
> (PoolTcpEndpoint.java:528) 
>         at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt 
> (LeaderFollowerWorkerThread.java:81) 
>         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run 
> (ThreadPool.java:685) 
>         at java.lang.Thread.run(Thread.java:619) 
> Caused by: javax.xml.bind.UnmarshalException 
> - with linked exception: 
> [com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </ 
> ns2:greetMe>; expected </arg0>. 
> at [row,col {unknown-source}]: [1,148]] 
>         at 
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamExcep­tion
>  
> (UnmarshallerImpl.java:426) 
>         at 
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0 
> (UnmarshallerImpl.java:362) 
>         at 
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal 
> (UnmarshallerImpl.java:339) 
>         at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall 
> (JAXBEncoderDecoder.java:607) 
>         ... 29 more 
> Caused by: com.ctc.wstx.exc.WstxParsingException: Unexpected close tag 
> </ns2:greetMe>; expected </arg0>. 
> at [row,col {unknown-source}]: [1,148] 
>         at com.ctc.wstx.sr.StreamScanner.constructWfcException 
> (StreamScanner.java:630) 
>         at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java: 
> 461) 
>         at com.ctc.wstx.sr.BasicStreamReader.reportWrongEndElem 
> (BasicStreamReader.java:3256) 
>         at com.ctc.wstx.sr.BasicStreamReader.readEndElem 
> (BasicStreamReader.java:3198) 
>         at com.ctc.wstx.sr.BasicStreamReader.nextFromTree 
> (BasicStreamReader.java:2830) 
>         at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java: 
> 1019) 
>         at org.apache.cxf.staxutils.DepthXMLStreamReader.next 
> (DepthXMLStreamReader.java:220) 
>         at 
> com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge 
> (StAXStreamConnector.java:225) 
>         at 
> com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0 
> (UnmarshallerImpl.java:360) 
>         ... 31 more 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to