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 Matt Williams <ma...@cancer.org.uk> on 2007/06/21 08:56:33 UTC
Accessing non-static methods
Dear All,
I'm having what I'm sure is a simple problem. I have some existing code
that I want to adapt to access via XML-RPC, but am having problems
instantiating and using objects.
At the moment I have code of the form:
MyObj o = new MyObj(x,y,z)
o.doSomething();
o.doSomething2();
I've adapted this to:
client.execute("o.init", [x,y,z])
client.execute ("o.doSomething",null)
where o.init() just calls the constructor. This works ok, but when I
make the second call via XML-RPC, I get a null error. I think this is
because the object o gets "lost", but I'm not sure.
Could someone give me some pointers as to what I should be doing ?
Thanks,
Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Matt Williams <ma...@cancer.org.uk>.
Excellent!
Thanks a lot.
Matt
Michael Landon - IBN wrote:
> You can always recreate "statefulness" by using keys to access a list or map
> of singleton data objects. Your server object would create/store init'd
> values for use on subsequent calls:
>
> client.execute("init", ["mykey",x,y,z]);
>
> would be handled as:
>
> // create new MyObj and associate it w/ "mykey" (if necessary)
> MyObj o = MyObj.getInstance("mykey");
> o.init(x,y,z)
>
> and
>
> client.execute("doSomething", ["mykey",b]);
>
> would be:
>
> // get existing MyObj associated w/ "mykey" (exception if doesn't exist)
> MyObj o = MyObj.getInstance("mykey");
> o.doSomething(b);
>
>
>
> Of course you'd have to clean-up the map/list occasionally...but there are
> several object pool implementations available for that type of situation.
>
> M
>
>
>
> -----Original Message-----
> From: Matt Williams [mailto:matthew.williams@cancer.org.uk]
> Sent: Friday, June 22, 2007 1:40 AM
> To: xmlrpc-dev@ws.apache.org
> Subject: Re: Accessing non-static methods
>
> Thanks for the comments & discussion, but I still have the problem.
>
> I tried tweaking the code such that I wasn't calling a method with null
> arguments:
>
> My Object is now of the form
>
> MyObj o = new MyObj(x,y,z)
>
> o.doSomething(Boolean b);
>
> I've adapted this to:
>
> client.execute("o.init", [x,y,z])
> client.execute ("o.doSomething", [b])
>
> but I'm still getting null errors; all the methods accept and return a
> value (although they're ignored), so I suspect the null is due to the
> "loss" of the object.
>
> I wonder if this is to do with the "Statelessness" of XML-RPC - I
> haven't read the code, but if it is stateless, then there's perhaps no
> carry over between the two calls.
>
> Can anyone give any advice on this?
>
> Thanks,
>
> Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Michael Landon - IBN <ml...@ibnads.com>.
You can always recreate "statefulness" by using keys to access a list or map
of singleton data objects. Your server object would create/store init'd
values for use on subsequent calls:
client.execute("init", ["mykey",x,y,z]);
would be handled as:
// create new MyObj and associate it w/ "mykey" (if necessary)
MyObj o = MyObj.getInstance("mykey");
o.init(x,y,z)
and
client.execute("doSomething", ["mykey",b]);
would be:
// get existing MyObj associated w/ "mykey" (exception if doesn't exist)
MyObj o = MyObj.getInstance("mykey");
o.doSomething(b);
Of course you'd have to clean-up the map/list occasionally...but there are
several object pool implementations available for that type of situation.
M
-----Original Message-----
From: Matt Williams [mailto:matthew.williams@cancer.org.uk]
Sent: Friday, June 22, 2007 1:40 AM
To: xmlrpc-dev@ws.apache.org
Subject: Re: Accessing non-static methods
Thanks for the comments & discussion, but I still have the problem.
I tried tweaking the code such that I wasn't calling a method with null
arguments:
My Object is now of the form
MyObj o = new MyObj(x,y,z)
o.doSomething(Boolean b);
I've adapted this to:
client.execute("o.init", [x,y,z])
client.execute ("o.doSomething", [b])
but I'm still getting null errors; all the methods accept and return a
value (although they're ignored), so I suspect the null is due to the
"loss" of the object.
I wonder if this is to do with the "Statelessness" of XML-RPC - I
haven't read the code, but if it is stateless, then there's perhaps no
carry over between the two calls.
Can anyone give any advice on this?
Thanks,
Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
RE: Accessing non-static methods
Posted by Andrew Norman <an...@piczoinc.com>.
Matt,
since you aren't returning a value from the first call perhaps you could
have the first call cause a redirect that invokes the second call
-andrew
-----Original Message-----
From: Matt Williams [mailto:matthew.williams@cancer.org.uk]
Sent: Friday, June 22, 2007 1:40 AM
To: xmlrpc-dev@ws.apache.org
Subject: Re: Accessing non-static methods
Thanks for the comments & discussion, but I still have the problem.
I tried tweaking the code such that I wasn't calling a method with null
arguments:
My Object is now of the form
MyObj o = new MyObj(x,y,z)
o.doSomething(Boolean b);
I've adapted this to:
client.execute("o.init", [x,y,z])
client.execute ("o.doSomething", [b])
but I'm still getting null errors; all the methods accept and return a
value (although they're ignored), so I suspect the null is due to the
"loss" of the object.
I wonder if this is to do with the "Statelessness" of XML-RPC - I
haven't read the code, but if it is stateless, then there's perhaps no
carry over between the two calls.
Can anyone give any advice on this?
Thanks,
Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Matt Williams <ma...@cancer.org.uk>.
Thanks for the comments & discussion, but I still have the problem.
I tried tweaking the code such that I wasn't calling a method with null
arguments:
My Object is now of the form
MyObj o = new MyObj(x,y,z)
o.doSomething(Boolean b);
I've adapted this to:
client.execute("o.init", [x,y,z])
client.execute ("o.doSomething", [b])
but I'm still getting null errors; all the methods accept and return a
value (although they're ignored), so I suspect the null is due to the
"loss" of the object.
I wonder if this is to do with the "Statelessness" of XML-RPC - I
haven't read the code, but if it is stateless, then there's perhaps no
carry over between the two calls.
Can anyone give any advice on this?
Thanks,
Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Daniel Noll <da...@nuix.com>.
On Friday 22 June 2007 09:51:49 Michael Landon - IBN wrote:
> We just return a b/Boolean to be ignored....
Well, problem is in our case we want to return either a struct (if the call
found a match) or null (if it didn't.) And I don't want the code on the
server to know about the limitations of the XML-RPC implementation. I'd
rather the client think it's calling a method that can return null, and the
server be able to return null without it generating an exception.
Daniel
--
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia Ph: +61 2 9280 0699
Web: http://nuix.com/ Fax: +61 2 9212 6902
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Michael Landon - IBN <ml...@ibnads.com>.
We just return a b/Boolean to be ignored....
----- Original Message -----
From: "Daniel Noll" <da...@nuix.com>
To: <xm...@ws.apache.org>
Sent: Thursday, June 21, 2007 5:34 PM
Subject: Re: Accessing non-static methods
On Friday 22 June 2007 00:17:02 Michael Landon - IBN wrote:
> Some versions of XML-RPC do not allow sending or receiving null. Check
> documentation to ensure that's not the problem.
Out of interest, what are people doing to get around this? Returning a
dummy
null object which then gets ignored by the wrapper on the client?
I was looking for a way where the client could still think it's calling a
method that returns null, and the server could still implement a method that
returns null, and everything in-between is hidden by magic wrappers.
Daniel
--
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia Ph: +61 2 9280 0699
Web: http://nuix.com/ Fax: +61 2 9212 6902
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Daniel Noll <da...@nuix.com>.
On Friday 22 June 2007 00:17:02 Michael Landon - IBN wrote:
> Some versions of XML-RPC do not allow sending or receiving null. Check to
> documentation to ensure that's not the problem.
Out of interest, what are people doing to get around this? Returning a dummy
null object which then gets ignored by the wrapper on the client?
I was looking for a way where the client could still think it's calling a
method that returns null, and the server could still implement a method that
returns null, and everything in-between is hidden by magic wrappers.
Daniel
--
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia Ph: +61 2 9280 0699
Web: http://nuix.com/ Fax: +61 2 9212 6902
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
Re: Accessing non-static methods
Posted by Michael Landon - IBN <ml...@ibnads.com>.
Some versions of XML-RPC do not allow sending or receiving null. Check to
documentation to ensure that's not the problem.
----- Original Message -----
From: "Matt Williams" <ma...@cancer.org.uk>
To: <xm...@ws.apache.org>
Sent: Thursday, June 21, 2007 12:56 AM
Subject: Accessing non-static methods
Dear All,
I'm having what I'm sure is a simple problem. I have some existing code
that I want to adapt to access via XML-RPC, but am having problems
instantiating and using objects.
At the moment I have code of the form:
MyObj o = new MyObj(x,y,z)
o.doSomething();
o.doSomething2();
I've adapted this to:
client.execute("o.init", [x,y,z])
client.execute ("o.doSomething",null)
where o.init() just calls the constructor. This works ok, but when I
make the second call via XML-RPC, I get a null error. I think this is
because the object o gets "lost", but I'm not sure.
Could someone give me some pointers as to what I should be doing ?
Thanks,
Matt
--
http://acl.icnet.uk/~mw
http://adhominem.blogsome.com/
+44 (0)7834 899570
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-dev-help@ws.apache.org