问题描述
我在互联网上发现问题在于,soap请求包含Unicode字符,,ctrl + v",这在Xml中是非法字符.我不知道这是如何进入String的,但是我想简单地在服务器端将其删除
I found on internet that problem is that soap request contain unicode char for ,,ctrl + v", which is illegal character in Xml. I dont know how this get into String, but I want simple to remove it on server side.
请问有人给我要点如何解决这个问题?我发现了这个片段:
Can plase someone give me the point how to solve this issue?I found this snippet :
XMLOutputFactory f = new WstxOutputFactory();
f.setProperty(WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER,
new InvalidCharHandler.ReplacingHandler(' '));
XMLStreamWriter sw = f.createXMLStreamWriter(...);
有人可以告诉我如何使用此处理程序配置Spring以构造WstxOutputFactory吗? - InvalidCharHandler.ReplacingHandler('').感谢您的建议.
Can someone tell me how to configure Spring for construction of WstxOutputFactory with this handler? - InvalidCharHandler.ReplacingHandler(' '). Thanks for advice.
推荐答案
解决方案非常简单:
<jaxws:endpoint id="kservice"
implementor="#kostrounService"
address="/call_kostroun" >
<jaxws:properties>
<entry key="javax.xml.stream.XMLOutputFactory" valueref="xmlOutputFactory" />
</jaxws:properties>
</jaxws:endpoint>
<bean id="invalidCharHandler" class="com.ctc.wstx.api.InvalidCharHandler$ReplacingHandler">
<constructor-arg value=" "/>
</bean>
<bean id="xmlOutputFactory" class="com.ctc.wstx.stax.WstxOutputFactory"/>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<ref local="xmlOutputFactory" />
</property>
<property name="targetMethod">
<value>setProperty</value>
</property>
<property name="arguments">
<list>
<util:constant static-field="com.ctc.wstx.api.WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER"/>
<ref bean="invalidCharHandler" />
</list>
</property>
</bean>
此配置摘要从soap消息中删除了非法字符,然后应用程序运行;-)
This snippet of configuration remove illegal characters from soap message, and app then run ;-)
这篇关于CXF-com.ctc.wstx.exc.WstxUnexpectedCharException:非法字符((CTRL-CHAR,代码5))的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!