• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is it right way to send exception to client

 
maha laxmi
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic