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!

3 thoughts on “Using Axis2 services from Javascript (by removing the XML namespaces)”

  1. 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.

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


Leave a Reply

Your email address will not be published. Required fields are marked *