You can't do this: Web services do SOAP Faults. Exceptions are platform-specific. When an exception is unhandled in an ASMX web service, .
NET will translate it into a SOAP Fault. The details of the exception are not serialized. In an ASMX client, a SOAP fault will be translated into a SoapException.
ASMX web services do not have proper support for SOAP Faults. There is no way to get any exception other than a SoapException on the client side. Yet another reason to upgrade to WCF.As an example of what you can't do with ASMX, here's how WCF works.
WCF allows you to specify, for each web service operation, which faults it can return: ServiceContract public interface IMyServiceContract { FaultContract(typeof(IntegerZeroFault)) FaultContract(typeof(SomeOtherFault)) OperationContract public string GetSomeString(int someInteger); } DataContract public class IntegerZeroFault { DataMember public string WhichInteger {get;set;} } DataContract public class SomeOtherFault { DataMember public string ErrorMessage {get;set;} } public class MyService : IMyServiceContract { public string GetSomeString(int someInteger) { if (someInteger == 0) throw new FaultException( new IntegerZeroFault{WhichInteger="someInteger"}); if (someInteger! = 42) throw new FaultException( new SomeOtherFault{ErrorMessage ="That's not the anaswer"}); return "Don't panic"; } } A WCF client can then catch FaultException, for instance. When I've tried this with a Java client, it was able to catch SomeOtherFault, which IBM Rational Web Developer created to derive from the Java Exception class.
If your goal is to throw an exception so that a user can know that something went wrong, some specific exception occurred and have special handling for it, you do have an option. You just have to rely on a correct implementation of the client proxy (Indeed, one option is to provide the client proxies yourself). There's a useful article availabe here about how SoapExceptions work.
Essentially, it comes down to encoding your exception details (eg an error code) in the detail node of the SoapException, and then parsing it on the client side before rethrowing the exception. There's no way to recreate the exception as if it were thrown across the service boundary, and there's no automagical way to get anything except for a SoapException on the client side.
In your client call to the WCF service that throws the Fault, you do try .. catch fault as FaultException(Of YourService. FooBarFault) end try You have to declare a FaultContract for the service method that can generate the fault, e.g. _ _ Function yourCall.
He's using ASMX. He calls it "ASP. NET Web Services" – John Saunders Aug 18 '09 at 21:53 Ah ok .. I thought he was using WCF – Larry Watanabe Aug 18 '09 at 22:55.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.