XML & Web services: Axis WS Client / WSDL2Java - trying to use CDATA elements

  1. I am trying to create an Apache Axis (1.4) web service client. The webservice client is a bit unusual in the sense that all it does is submit an XML payload of various data to the server, and all it gets back is an 'OK' message. We have a WSDL and used WSDL2Java to create the shell of the client code. So, the relevant code in the generated files looks like this: static { elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("request"); elemField.setXmlName(new javax.xml.namespace.QName("http://xmlns.acme.com", "Request")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField = new org.apache.axis.description.ElementDesc(); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); } This "Request" field is our XML payload, and we need it to be wrapped in CDATA[]. However, after hours of searching, I have no idea how to denote to Axis to serialize this element as CDATA, rather than escaped text. So my questions are: 1) How can I do this? Is it even possible in Axis with WSDL2Java? Is there an easier way to do this if I don't use WSDL2Java? 2) We are not married to Axis - is there an alternative library I should try? (It is a very simple webservice to be invoked by Cron job... I'm looking for the simplest possible way to invoke this service) Thank you.
  2. The irony was that even though it only accepted unencoded XML strings surrounded by CDATA, it would turn around and spit back out fully encoded responses. The hacked solution I came up with (with no help from Google) was to override the org.apache.axis.components.encoding.XMLEncoder with my own implementation that left the characters needed for XML tags well alone (JAD is your friend). To enable your XMLEncoder you need to add a META-INF/services/org.apache.axis.components.encoding.XMLEncoder file containing the FQN of the class (Commons Discovery is another badly documented project).