Using Axis2 services from Javascript (by removing the XML namespaces)

If you want to call an Axis2 service from Javascript you will face the problem that the XML response of an Axis2 service call contains XML namespaces – something Javascript doesn’t like in cross-browser-friendly way.
The idea to fix this issue is to make an XSLT transformation directly from Axis2 that removes the unnecessary namespaces.

First we need an XSLT transformation that will do the job:

Then we’ll need a hand-made Axis2 conform MessageFormatter that uses the standard formatter for XML and performs the XSLT transformation on the result:

(Don’t forget to adjust the path of removeNamespaces.xsl, so the formatter can find the .xsl!)

Finally just put the class of the newly created formatter in WEB-INF/classes of your Axis2 deployment and replace the reference in the axis2.xml configuration file.
For this just exchange the line:


After a restart of your application server you should be able to use your Axis2 services from Javascript – Have fun!