问题描述
apache的cxf2.3.3原生不支持hashmap的传送,官方在其发布包中给出了一个【java_first_jaxws】工程,该工程运行之后可以正常支持源生hashmap了,可是只要我在hashmap中放入的不是英文,是中文,他就报错:org.apache.cxf.interceptor.Fault:MarshallingError:nullatorg.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshalWithBridge(JAXBEncoderDecoder.java:327)atorg.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:124)atorg.apache.cxf.interceptor.DocLiteralInInterceptor.getPara(DocLiteralInInterceptor.java:251)atorg.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:127)atorg.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)atorg.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:755)atorg.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2335)atorg.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2193)atorg.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2037)atorg.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)atorg.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:188)atorg.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)atorg.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:697)atorg.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)atorg.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)atorg.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)atorg.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)atorg.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)atorg.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)atorg.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)at$Proxy61.getMapByCXFDocument(UnknownSource)atcom.webservice.cxf.CxfSoapAction.runWebService(CxfSoapAction.java:77)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:592)atorg.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:740)atorg.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:744)atorg.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:593)atorg.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:90)atorg.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)atorg.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:637)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:717)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)atjava.lang.Thread.run(Thread.java:595)Causedby:java.lang.reflect.UndeclaredThrowableExceptionat$Proxy74.unmarshal(UnknownSource)atorg.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshalWithBridge(JAXBEncoderDecoder.java:312)...49moreCausedby:java.lang.reflect.InvocationTargetExceptionatsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)atjava.lang.reflect.Method.invoke(Method.java:592)atorg.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:52)...51moreCausedby:javax.xml.bind.UnmarshalException-withlinkedexception:[javax.xml.stream.XMLStreamException:Invalidbyte1of1-byteUTF-8sequence.]atcom.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426)atcom.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)atcom.sun.xml.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:120)atcom.sun.xml.bind.v2.runtime.BridgeAdapter.unmarshal(BridgeAdapter.java:124)atcom.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:233)...56moreCausedby:javax.xml.stream.XMLStreamException:Invalidbyte1of1-byteUTF-8sequence.atcom.sun.xml.stream.XMLReaderImpl.next(XMLReaderImpl.java:560)atorg.apache.cxf.staxutils.DepthXMLStreamReader.next(DepthXMLStreamReader.java:220)atcom.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)atcom.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)...59more不知道大家遇到这种情况了么?还是想其他办法绕过去,不直接传送hashmap,传送arraylist???或者有什么好的解决办法否?
解决方案
解决方案二:
不懂这个,用axis生成过
解决方案三:
现在多用cxf了吧?虽然可以用arraylist替代,可是总觉得不应该这样啊。官方提供的例子啊,修改为中文就不行了。
解决方案四:
CXF使用JAXB进行序列化的,可以设置成HashMap的。
解决方案五:
你可以网上搜一下“JAXBhashmap”
解决方案六:
该回复于2011-03-14 13:34:25被版主删除