File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes is it right way to send exception to client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "is it right way to send exception to client" Watch "is it right way to send exception to client" New topic

is it right way to send exception to client

maha laxmi
Ranch Hand

Joined: Sep 23, 2005
Posts: 68
here i pasted webservice,client classes and sample of wsdl file;

Is it right to catch EmpFaultException in client code;Is any other way to do it;

if empMaster is null i want to throw the message to the user.


public interface Employee extends java.rmi.Remote {
public boolean withdraw(java.lang.String account, int amount)
throws java.rmi.RemoteException,

EmpResponseType[] empMaster;

empMaster = stub.withdraw(requestType);
}catch(EmpFaultException e)
out.println("Could not find Employee");


sample of wsdl

<xsd:schema targetNamespace="">
<xsd:element name="EmpFault">
<xsd:element name="info" type="xsd:string"/>

<wsdl:message name="EmpFaultMessage">
<wsdl art element="impl:EmpFault" name="fault"/>

<wsdl ortType name="EmpPortType">
<wsdl peration name="getEmp">
<wsdl:input message="impl:getEmpRequest" name="getEmpRequest"/>
<wsdl utput message="impl:getEmpResponse" name="getEmpResponse"/>
<wsdl:fault message="impl:EmpFaultMessage" name="EmpFaultException"/>
</wsdl peration>
</wsdl ortType>

checked exception::::
public class EmpFaultException
extends java.lang.Exception
implements {
private java.lang.String info;

public EmpFaultException() {

public EmpFaultException(
java.lang.String info) { = info;

public java.lang.String getInfo() {
return info;

public void setInfo(java.lang.String info) { = info;
I agree. Here's the link:
subject: is it right way to send exception to client
It's not a secret anymore!