redstone.xmlrpc.XmlRpcDispatcher writeError

  • wim verreycken

    wim verreycken - 2008-03-08

    Hi everyone,

    I am trying to write a simple service that transfers funds from on account to another. It can also say hello, for testing purposes. The interface is this :

        public interface FundsTransferService {
            public String transferFunds(float amount, int srcAcctNumber, int
                    targetRoutingNumber, int targetAcctNumber);
            public String sayHello(String user, String message);

    On my client side, when i do
         XmlRpcClient client = new XmlRpcClient( "", false );
        result = client.invoke("FundsTransferService.sayHello", new Object[] {"wim", "Have a very nice day!"} );

    the service responds with :
        Hello wim . Have a very nice day!
        This is the FundsTransferServiceImpl.

    But when trying to invoke the transferFunds method by doing this :
        result = client.invoke("FundsTransferService.transferFunds", new Object[] {(float)123.5, 310, 641, 657});
    I get a runtime error on the client side and a warning on the server side.

    On the client side :
        Exception in thread "main" redstone.xmlrpc.XmlRpcFault: java.lang.IllegalArgumentException: argument type mismatch
            at redstone.xmlrpc.XmlRpcClient.handleResponse(Unknown Source)
            at redstone.xmlrpc.XmlRpcClient.endCall(Unknown Source)
            at redstone.xmlrpc.XmlRpcClient.invoke(Unknown Source)
            at test.TestClient2.main(

    And on the server side :
        8-mrt-2008 14:10:44 redstone.xmlrpc.XmlRpcDispatcher writeError
        WARNING: java.lang.IllegalArgumentException: argument type mismatch

    Can anyone help me with this? Also, where can I find more information on which types are supported and how they are mapped?
    Thank you,


    • Greger Ohlson

      Greger Ohlson - 2008-03-08


      The XML-RPC spec does not support floats. It supports doubles however, so the
      fix for your problem is to have your invocation handler accept doubles instead
      of floats, and also adjust your FundsTransferService accordingly.

      Now, modifying your FundsTransferService is actually optional because the
      serializer in the Redstone library knows how to serialize floats. But since
      XML-RPC does not support floats they are converted to doubles before being
      sent over the wire to the service. So when the value arrives at the service
      (in XML-RPC form) it is deserialized into a double which means that your service
      should be ready to accept a double.

      It would be possible for the deserializing mechanism to downsize doubles to
      floats at the server side but that would be potentially dangerous since they don't have
      the same range/capacity.

      So, I'd suggest changing the interface to accept doubles and you could also have
      your invocation handler implement the interface so you'd be sure that the client
      (which uses the interface in an XmlRpcProxy I assume) and the server (which implements
      the interface) agree on the exact same interface. Again, this is purely optional
      but a nice way to ensure that clients and servers have agreed on the interface at
      compilation time.



    • wim verreycken

      wim verreycken - 2008-03-08

      Hi Greger,

      This fixed it for me. Are there any other "catches" when using xml-rpc
      that I need to be aware of? Other not supported primitive types f.e.?

      I'll take a closer look at the spec in the meantime :)




Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks