开发者

Handle SOAP exception cases with several catch blocks

This(*) ObjectLockedException returned from a Java-based 开发者_如何转开发web service. I want to catch this specific error on .NET.

I use C#. Can anyone suggest a method for the code below? I mean how can I make it work?

try{
 service.something();

}catch(ObjectLockedException exx)
{
  alert("Hey!, remove the lock");
}
catch
{
//this block is for the rest of the exceptions
}

(*)The Detailed Explnation OF Exception That I want to catch; java.rmi.RemoteException: error while preparing instance QS.TYR.611; nested exception is: xy.zrt.ugy.business.ObjectLockedException: Could not obtain lock for QS.TYR.611


If the "something" operation in your service has a fault contract then there will be a detail type that contains the error information for the fault. Look for FaultContractAttribute in your service interface. Given this type, T, you can catch FaultException<T>.

If there is no fault contract, you'll have to catch FaultException and pick it apart.

It's unlikely that you can catch the nested exception directly... but it ultimately depends on the fault contract.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜