I'm trying to build a Java SOAP Client (XML type requests). Using Axis as SOAP library and Jackson as serialization/de-serialization library.
There is a section in request body which the server expects plain text.
Example: Server expects exactly below in request body for a particular XmlElement and a request using Postman works in below format.
......
......
<XmlElement>
<![CDATA[
{
"Employee" : {
"name" : "xyz",
"email" : "abc"
},
"Company" : {
"name" : "xyz",
"location" : "abc"
}
}
]]>
</XmlElement>
.....
.....
In order to achieve above, I've
- Defined Employee and Company POJOs with Json Annotations
- Built the Java object
- Serialize to string using objectMapper.writeValueAsString()
- Wrapped String with "CDATA" as shown in above example
Problem: Axis library that is building the SOAP request, is creating below request which is failing with "BAD XML paramters" from server. It is essentially converting special characters like <, >, & into < , '>' and '"' respectively. I've read that this is common in XML world.
Axis generated request body is as follows
......
......
<XmlElement>
<![CDATA[
{
"Employee"`; : {
"name" : "xyz",
"email" : "abc"
},
"Company" : {
"name" : "xyz",
"location" : "abc"
}
}
]]>
</XmlElement>
.....
.....
I've gone through similar posts but could not understand how to get around this problem?
- Is there a property which can be disabled to avoid this conversion of special characters?
- Is there a different SOAP library to use that doesn't do this translation?
- Is there a different way to wrap CData?
- Should server be changed to handle this case?
Am I missing something very basic here?
Explored different properties on the Axis library code that got generated, could not find any relevant ones to disable this translation. Went through almost all stackoverflow posts which are similar but couldn't find anything that worked for this use-case.