RPC With A Dynamic Number of Variables

2008-07-15 Thread Elam Daly
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

2008-07-15 Thread Jochen Wiedmann
On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly [EMAIL PROTECTED] 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

2008-07-15 Thread Elam Daly
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 [EMAIL PROTECTED]
wrote:

 On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly [EMAIL PROTECTED] 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

2008-07-15 Thread Stanislav Miklik
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED]
 wrote:

 On Tue, Jul 15, 2008 at 3:51 PM, Elam Daly [EMAIL PROTECTED] 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

2008-07-15 Thread Elam Daly
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 [EMAIL PROTECTED]
wrote:

 On Tue, Jul 15, 2008 at 5:13 PM, Elam Daly [EMAIL PROTECTED] 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

2008-07-15 Thread Craig Kelley
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] for PGP block


Re: RPC With A Dynamic Number of Variables

2008-07-15 Thread Stanislav Miklik
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] for PGP block



Re: RPC With A Dynamic Number of Variables

2008-07-15 Thread Elam Daly
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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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
 [EMAIL PROTECTED] for PGP block