'Problem with xml characters escaping in spring soap request object
I use spring web services and i want to send soap request via WebServiceTemplate, but the object to send contains a string with <, > character and these characters got escaped as bellow :
<![CDATA[<greeting>Hello, world!</greeting>]]>
But i want the result to be :
<![CDATA[<greeting>Hello, world!</greeting>]]>
Here is my soap config :
@Bean
public Jaxb2Marshaller marshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("packageName");
Map<String, Object> props = new HashMap<>();
props.put(Marshaller.JAXB_FORMATTED_OUTPUT, true);
CharacterEscapeHandler escapeHandler = NoEscapeHandler.theInstance;
props.put("com.sun.xml.bind.characterEscapeHandler", escapeHandler);
props.put("com.sun.xml.bind.marshaller.CharacterEscapeHandler", escapeHandler);
props.put(Marshaller.JAXB_ENCODING, "utf-8");
marshaller.setMarshallerProperties(props);
return marshaller;
}
@Bean
public SoapClient soapClient(@Value("${soap.url}") String url) {
SoapClient client = new SoapClient();
client.setDefaultUri(url);
client.setMarshaller(marshaller());
client.setUnmarshaller(marshaller());
return client;
}
How can i get the result with <, > character, without escaping ? I need your help please!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
