Search code examples
web-servicestomcatapache-axis

Encoding of spaces in POJO parameters in Axis2


I have created a very simple service that just echos some text to the console. The service is just a POJO with a method echo, having a single parameter:

public class EchoTest
{
    public void echo(String myMessage)
    {
        System.out.println(myMessage);
    }
}

Ths is from the services.xml:

<service name="EchoTest">
    <description>Echo test</description>
    <parameter name="ServiceClass">EchoTest</parameter>

     <operation name="echo">
        <messageReceiver  class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
    </operation>
</service>

Further I use a very simple HTML form to submit the data to the service:

<html>
<body>
    <form method="post" target="responseFrame" action="../../services/EchoTest/echo">
        <input name="myMessage" type="text">
        <input value="Send" type="submit"/>         
    </form>
    <iframe width=500 height=500 name="responseFrame"></iframe>
</body>
</html>

The problem I have is that spaces are replaced with '+'. For example, if I type a message like this:

Hey you & you - # % @

The result is this:

Hey+you+&+you+-+#+%+@

Do I have to encode it somehow or or should it not behave like this? Or perhaps it is a setup issue? I am using Tomcat as a web container. For information, I use a servlet filter in Tomcat to e.g. filter on IP addresses, and in there I can see that the myMessage parameter looks OK, not having + signs.


Solution

  • It turns out that the problem was in fact within Axis2 itself. I am not sure exactly, but the version that I was using was release 1.5.1 from October 2009. What bugs me is that I have not found any bug report on it. It could be that it was fixed quickly and that I was unfortunate.

    Upgrading to a the latest version of Axis2 solved the problem.