Two Laptop Bag*
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
Author

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.



webservice
**********

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

client
********
EmpResponseType[] empMaster;

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

}

sample of wsdl
****************

<wsdl:types>
<xsd:schema targetNamespace="http://emp.com/services/Emp">
<xsd:element name="EmpFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="info" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>


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

<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 java.io.Serializable {
private java.lang.String info;

public EmpFaultException() {
}

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

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

public void setInfo(java.lang.String info) {
this.info = info;
}
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: is it right way to send exception to client
 
Similar Threads
Calling a web service in Axis2
jax-ws clients and jboss
Web Service Client using IBM Web sphere JAX-WS runtime Issue
Axis WSDL2Java's Error: reference but not defined
Problem of create Web Service Client