问题
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(...);
Can someone tell me how to configure Spring for construction of WstxOutputFactory with this handler? - InvalidCharHandler.ReplacingHandler(' '). Thanks for advice.
回答1:
The solution is pretty simple :
<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>
This snippet of configuration remove illegal characters from soap message, and app then run ;-)
来源:https://stackoverflow.com/questions/12061766/cxf-com-ctc-wstx-exc-wstxunexpectedcharexception-illegal-character-ctrl-cha