gpol
gpol

Reputation: 966

How to ignore invalid xml response with Spring's JaxWsPortProxyFactoryBean

I am using the JaxWsPortProxyFactoryBean to create a simple ws client from a wsdl. Everything works as expected but unfortunately the response I am getting contains unicode characters which are invalid in xml documents. Unfortunately this is a third-party web service and the owner cannot change the content currently. Consequently I am getting exceptions like the following:

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1563]
Message: An invalid XML character (Unicode: 0x1a) was found in the element content of the document.

Is there anyway to ignore these errors, receive the response and clear it out myself? If not, is there any "proper" or "usual" way to handle with these kinds of situations?

Thanks

Upvotes: 1

Views: 2311

Answers (1)

Aravind Yarram
Aravind Yarram

Reputation: 80194

The issue is that 0x1a is NOT in the valid character set range for XML. May be this solution is what you are looking for i.e. removing the invalid character your self using some sort of filter/interceptor may be..

Also, read this post for another alternate solution which is to replace it with the UNICODE Replacement character.

Upvotes: 1

Related Questions