[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlrpc-user
Subject:    Generating Server Exception and Catching on Client
From:       "tcorbet" <tcorbet () ix ! netcom ! com>
Date:       2005-05-15 17:55:18
Message-ID: 001501c55977$425cb780$0200a8c0 () hq ! sss ! com
[Download RAW message or body]

I am using this library for both client-side and server-side processing.
On the server side, I have followed the example for incorporation as a
Servlet, and am using Tomcat 5.5.

I thought it would be *nice* to be able to return an Exception from the
Servlet when the service cannot return the desired result.  The =
HTTPServlet
service method has a signature which throws ServletException and
IOException.  I thought I should try to throw an XmlRpcException, but
the compiler won't let me get away with that.

So, I throw a ServletException, but my catch block inside =
XmlRpcClientLite's
execute method does not catch the ServletException.  Even if I try to
catch Exception, something at a lower layer catches the ServletException
and shuts me down.

Is there a snippet or other tutorial describing how to communicate =
between
the server and the client via an exception?  Not being able to solve the
problem, I have resorted to the ugly, but functional, solution of =
sending back
error codes wrapped in XML.  It means lots of 'instanceof' checks so =
that
any given RPC call can check for an error before it checks for the type =
of
object that it will receive when the execute is successful.

Thank you.

[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1491" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>I am using this library for both client-side and 
server-side processing.</FONT></DIV>
<DIV><FONT face=Arial size=2>On the server side, I have followed the example for 
incorporation as a</FONT></DIV>
<DIV><FONT face=Arial size=2>Servlet, and am using Tomcat 5.5.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>I thought it would be *nice* to be able to return 
an Exception from the</FONT></DIV>
<DIV><FONT face=Arial size=2>Servlet when the service cannot return the desired 
result.&nbsp; The HTTPServlet</FONT></DIV>
<DIV><FONT face=Arial size=2>service method has a signature which throws 
ServletException and</FONT></DIV>
<DIV><FONT face=Arial size=2>IOException.&nbsp; I thought I should try to throw 
an XmlRpcException, but</FONT></DIV>
<DIV><FONT face=Arial size=2>the compiler won't let me get away with 
that.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>So, I throw a ServletException, but my catch block 
inside XmlRpcClientLite's</FONT></DIV>
<DIV><FONT face=Arial size=2>execute method does not catch the 
ServletException.&nbsp; Even if I try to</FONT></DIV>
<DIV><FONT face=Arial size=2>catch Exception, something at a lower layer catches 
the ServletException</FONT></DIV>
<DIV><FONT face=Arial size=2>and shuts me down.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Is there a snippet or other tutorial describing how 
to communicate between</FONT></DIV>
<DIV><FONT face=Arial size=2>the server and the client via an exception?&nbsp; 
Not being able to solve the</FONT></DIV>
<DIV><FONT face=Arial size=2>problem, I have resorted to the ugly, but 
functional, solution of sending back</FONT></DIV>
<DIV><FONT face=Arial size=2>error codes wrapped in XML.&nbsp; It means lots of 
'instanceof' checks so that</FONT></DIV>
<DIV><FONT face=Arial size=2>any given RPC call can check for an error before it 
checks for the type of</FONT></DIV>
<DIV><FONT face=Arial size=2>object that it will receive when the execute is 
successful.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thank you.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></FONT></DIV></BODY></HTML>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic