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!

  • Thanks for useful information. I want to remove the tag itself not just the namespace declaration. Do you know is there a way to do this?

  • Rama

    Hi, Thanks for the very useful post.
    I followed the steps above, but looks like writeTo() method is not being called and transformation is not happening.

    basically I included the logger statements in constructor and writeTo() method of ApplicationXMLFormatter class.

    But the logger statement in the writeTo() is not being printed in log file, although the one in constructor is being printed.

    Appreciate your help.

  • Karan

    where i create a xsl file in project directory my xml file is look like this