You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Elam Daly <el...@gmail.com> on 2008/07/15 15:51:25 UTC

RPC With A Dynamic Number of Variables

Hi All,

We have a client who is expecting us to create an XML-RPC service with a
dynamic number of variables, ie myRPC(var_1,var_2, var_x);

Considering the static nature of the ws-xmlrpc library, I don't see how I
can achieve this without using a Filter or something similar.

Any suggestions are appreciated.

- Elam Daly

Re: RPC With A Dynamic Number of Variables

Posted by Stanislav Miklik <st...@gmail.com>.
Hi,

If I have understood it correctly, there is no problem with such methods.

Here is example from the site:
    Object[] params = new Object[]{new Integer(33), new Integer(9)};
    Integer result = (Integer) client.execute("Calculator.add", params);

Also execute method takes parameters in the Object[] object. And then
this array object is translated to XML RPC as param1, param2, ...
paramX  (not one parameter of array type!). And that is exactly what
you want, isn't it?

BR
Stano

On Tue, Jul 15, 2008 at 17:15, Elam Daly <el...@gmail.com> wrote:
> I agree Jochen, but this is the client's already implemented specification
> and I don't have control over changing it at this point.
>
> Browsing the archives, it seems that a Filter is not the best choice to
> correct this though.
>
> - Elam
>
>
> On Tue, Jul 15, 2008 at 11:11 AM, Jochen Wiedmann <jo...@gmail.com>
> wrote:
>
>> On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly <el...@gmail.com> wrote:
>>
>> > We have a client who is expecting us to create an XML-RPC service with a
>> > dynamic number of variables, ie myRPC(var_1,var_2, var_x);
>> >
>> > Considering the static nature of the ws-xmlrpc library, I don't see how I
>> > can achieve this without using a Filter or something similar.
>>
>> Why not simply using an Object[] or a List?
>>
>> Jochen
>>
>> --
>> Look, that's why there's rules, understand? So that you think before
>> you break 'em.
>>
>>  -- (Terry Pratchett, Thief of Time)
>>
>

Re: RPC With A Dynamic Number of Variables

Posted by Elam Daly <el...@gmail.com>.
I agree Jochen, but this is the client's already implemented specification
and I don't have control over changing it at this point.

Browsing the archives, it seems that a Filter is not the best choice to
correct this though.

- Elam


On Tue, Jul 15, 2008 at 11:11 AM, Jochen Wiedmann <jo...@gmail.com>
wrote:

> On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly <el...@gmail.com> wrote:
>
> > We have a client who is expecting us to create an XML-RPC service with a
> > dynamic number of variables, ie myRPC(var_1,var_2, var_x);
> >
> > Considering the static nature of the ws-xmlrpc library, I don't see how I
> > can achieve this without using a Filter or something similar.
>
> Why not simply using an Object[] or a List?
>
> Jochen
>
> --
> Look, that's why there's rules, understand? So that you think before
> you break 'em.
>
>  -- (Terry Pratchett, Thief of Time)
>

Re: RPC With A Dynamic Number of Variables

Posted by Stanislav Miklik <st...@gmail.com>.
Hi *,

sorry, I read it to quickly (I assumed that server is fixed, not the
client) ;-) As Craig said, there is a solution with making your own
handler and then from XmlRpcRequest you can get any number of
parameters.

Check eg.
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/server/XmlRpcServer.html#setHandlerMapping(org.apache.xmlrpc.server.XmlRpcHandlerMapping)
http://ws.apache.org/xmlrpc/apidocs/org/apache/xmlrpc/XmlRpcRequest.html

Stano

On Tue, Jul 15, 2008 at 17:44, Craig Kelley <na...@gmail.com> wrote:
> Hi Elam,
>
> I'm not certain about XMLRPC 3.x, but with 1.x you could override the
> execute() method for XmlRpcHandler and do this sort of thing.  We use
> it along with introspection to route calls to various places.
>
>  -Craig
>
> On Tue, Jul 15, 2008 at 9:39 AM, Elam Daly <el...@gmail.com> wrote:
>> Jochen,
>>
>> just so I'm clear, are you suggesting to change my current method signature
>> from myRPC(var_1, var_2, var_x) to myRPC(Object[] obja) and then parse the
>> array and forward to the appropriate method?
>>
>> Stano,
>>
>> The client is using PHP and when they try and execute my RPC, they get an
>> error claiming the method doesn't exist because there isn't one matching the
>> method signature that they are trying to use.
>>
>> If I call the calculator RPC with Object[] params = new Object[]{new
>> Integer(33), new Integer(9), new Integer(10)};. afaik that won't work
>> because the add method is only expecting 2 parameters, not 3.
>
> --
> http://inconnu.islug.org/~ink finger ink@inconnu.islug.org for PGP block
>

Re: RPC With A Dynamic Number of Variables

Posted by Elam Daly <el...@gmail.com>.
Thanks for the replies.

I don't suppose I could get a small bit of direction here?

My original setup is exactly like the calculator demo.  Am I now to change
my class to extend the XmlRpcServlet class and implement a custom
XmlRpcHandler, similar to the documentation example of Basic Authentication?

- Elam

On Tue, Jul 15, 2008 at 11:44 AM, Craig Kelley <na...@gmail.com> wrote:

> Hi Elam,
>
> I'm not certain about XMLRPC 3.x, but with 1.x you could override the
> execute() method for XmlRpcHandler and do this sort of thing.  We use
> it along with introspection to route calls to various places.
>
>  -Craig
>
> On Tue, Jul 15, 2008 at 9:39 AM, Elam Daly <el...@gmail.com> wrote:
> > Jochen,
> >
> > just so I'm clear, are you suggesting to change my current method
> signature
> > from myRPC(var_1, var_2, var_x) to myRPC(Object[] obja) and then parse
> the
> > array and forward to the appropriate method?
> >
> > Stano,
> >
> > The client is using PHP and when they try and execute my RPC, they get an
> > error claiming the method doesn't exist because there isn't one matching
> the
> > method signature that they are trying to use.
> >
> > If I call the calculator RPC with Object[] params = new Object[]{new
> > Integer(33), new Integer(9), new Integer(10)};. afaik that won't work
> > because the add method is only expecting 2 parameters, not 3.
>
> --
> http://inconnu.islug.org/~ink <http://inconnu.islug.org/%7Eink> finger
> ink@inconnu.islug.org for PGP block
>

Re: RPC With A Dynamic Number of Variables

Posted by Craig Kelley <na...@gmail.com>.
Hi Elam,

I'm not certain about XMLRPC 3.x, but with 1.x you could override the
execute() method for XmlRpcHandler and do this sort of thing.  We use
it along with introspection to route calls to various places.

 -Craig

On Tue, Jul 15, 2008 at 9:39 AM, Elam Daly <el...@gmail.com> wrote:
> Jochen,
>
> just so I'm clear, are you suggesting to change my current method signature
> from myRPC(var_1, var_2, var_x) to myRPC(Object[] obja) and then parse the
> array and forward to the appropriate method?
>
> Stano,
>
> The client is using PHP and when they try and execute my RPC, they get an
> error claiming the method doesn't exist because there isn't one matching the
> method signature that they are trying to use.
>
> If I call the calculator RPC with Object[] params = new Object[]{new
> Integer(33), new Integer(9), new Integer(10)};. afaik that won't work
> because the add method is only expecting 2 parameters, not 3.

-- 
http://inconnu.islug.org/~ink finger ink@inconnu.islug.org for PGP block

Re: RPC With A Dynamic Number of Variables

Posted by Elam Daly <el...@gmail.com>.
Jochen,

just so I'm clear, are you suggesting to change my current method signature
from myRPC(var_1, var_2, var_x) to myRPC(Object[] obja) and then parse the
array and forward to the appropriate method?

Stano,

The client is using PHP and when they try and execute my RPC, they get an
error claiming the method doesn't exist because there isn't one matching the
method signature that they are trying to use.

If I call the calculator RPC with Object[] params = new Object[]{new
Integer(33), new Integer(9), new Integer(10)};. afaik that won't work
because the add method is only expecting 2 parameters, not 3.

- Elam

On Tue, Jul 15, 2008 at 11:22 AM, Jochen Wiedmann <jo...@gmail.com>
wrote:

> On Tue, Jul 15, 2008 at 5:13 PM, Elam Daly <el...@gmail.com> wrote:
>
> > I agree Jochen, but this is the client's already implemented
> specification
> > and I don't have control over changing it at this point.
>
> Sure you don't? Note that Java varargs methods are actually using
> object arrays internally.
>
>
> > Browsing the archives, it seems that a Filter is not the best choice to
> > correct this though.
>
> Ok, I would do this by using a wrapper. For example, on the server
> side, I'd have a method that takes an object array, chooses the actual
> method by looking at the array elements and delegates the call to the
> actual method, possibly by using reflection.
>
> On the client side, you could provide a Java varargs method that takes
> the object array as an input and calls the wrapper.
>
>
> Jochen
>
>
> --
> Look, that's why there's rules, understand? So that you think before
> you break 'em.
>
>  -- (Terry Pratchett, Thief of Time)
>

Re: RPC With A Dynamic Number of Variables

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly <el...@gmail.com> wrote:

> We have a client who is expecting us to create an XML-RPC service with a
> dynamic number of variables, ie myRPC(var_1,var_2, var_x);
>
> Considering the static nature of the ws-xmlrpc library, I don't see how I
> can achieve this without using a Filter or something similar.

Why not simply using an Object[] or a List?

Jochen

-- 
Look, that's why there's rules, understand? So that you think before
you break 'em.

 -- (Terry Pratchett, Thief of Time)