Sunday, 13 December 2015

XML : How can I force Axis2 to send xml decleration?

I have to run a JAX-WS web service client inside of WebSphere 7. Connecting to a ASP.NET web service.

When calling it I receive the following error:

javax.xml.ws.soap.SOAPFaultException: Server was unable to process request. ---> Unable to cast object of type 'System.Xml.XmlElement' to type 'System.Xml.XmlDeclaration'.

Doing some SOAPUI tests I found that adding

  <?xml version="1.0" encoding="utf-8"?>    

would fix the problem.

I tried to force the xml header by adding a SOAPHandler which sets.

  soapMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");  soapMsg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");    

But without success. Is there an Axis2 way of forcing the deceleration?

No comments:

Post a Comment