ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Waldron, Terry" <waldr...@KGH.KARI.NET>
Subject RE: [Newbie Quetion] How can I check my RPC return value
Date Fri, 19 Mar 2004 18:14:52 GMT
Try Catch Block will do the trick...

-----Original Message-----
From: Dave Stewart [mailto:dstewart@aquaflo.com]
Sent: March 19, 2004 1:00 PM
To: xmlrpc-user@ws.apache.org
Subject: Re: [Newbie Quetion] How can I check my RPC return value


Hi Bagas! 

(Caution: I'm not any certified expert in any way, just played with this myself a bit ...)


I'm not sure I'm following your question, but I'll give it a shot anyway ... 


On Mar 18, 2004, at 10:49 PM, bagas wrote: 


Dear All,  

I am building a XML-RPC Server using org.apache.xmlrpc.WebServer. 
I now encounter a problem; the problem is how can I track my response (result).  

Here is an example :  

Suppose I have a Class =  

Public class AServer implements XmlRpcHandler 
{ 
            WebServer serv; 

            public static void main(String [] args) 
            { 
                        Aserver(100); 
            }            

            public AServer(int i) 
            { 
                        serv = Webserver(i); 
                        serv.addHandler("$default", this); 
            } 

public Object execute(String method, Vector params) 
            { 
                        //do something 
                        return something; 
            } 
}  

after AServer running ….. there are 3 message coming ….. 


Um, clarification here ... you mean you've called execute with a method name and 3 arguments
in params, right? 



then the server send a response (result of the method) right ?? 


According to the documentation, execute() should either return a result *OR THROW AN EXCEPTION*.
The result will be a java.lang.Object unless something went wrong, in which case it will throw
a java.lang.Exception that will need to be caught somewhere. 





My question is how can I track the response (result) of the message if I urgently needed to
know whether the response (result) is sent or fail to be sent. 


Well, how is your server (AServer) dealing with it? You could either be trapping the exception
with a try/catch block or passing it back to the caller (the class that invoked execute()
and sent 3 messages in params). 

Maybe that's the hint you need, the documentation for the interface XmlRpcHandler specifies
that the execute() method will either return a result (as a java.lang.Object) or will throw
an exception (specifically a java.lang.Exception). If the result was sent, it will be in the
Object returned. If it failed, details will be in the Exception. 

If you are trapping that Exception in AServer itself, then I would suggest creating an Object
that you could return that will be recognized as a problem and testing for that in the calling
method. If you are passing the Exception back to the invoker (which is what I would do), then
I don't get the question since it should be obvious if it worked or not (you'll either get
an Object back or you'll catch an Exception, which kind of answers the question doesn't it?)






Thank you very much … 


I just hope I've been of some help. ;-) 



Dave Stewart 
Aqua~Flo Supply (Goleta CA) 
dstewart at aquaflo dot com 

Law of Probability Dispersal: 
Whatever it is that hits the fan 
will not be evenly distributed. 


Mime
View raw message