Re: WCF wrapping proxy calls to catch errors
by Spam Catcher on 12/5/2007 8:46:00 AM
=?Utf-8?B?S2lrZQ==?= <Kike@discussions.microsoft.com> wrote in
news:985239CD-8EE8-4631-8A19-53AB79D32F11@microsoft.com:
> Hello,
>
> I need to be able to somehow wrap calls made through a standard
> Interface used to access a WCF service. The reason for this is to have
> a higher degree of control, mainly to catch all kinds of exceptions
> transperently, and maybe translate them to other exception types.
>
> I've tried to wrap the interface with a class but that way I can only
> invoke methods of the interface passing a string to an execute method
> (wrapper.Execute("MyMethod")) instead of directly
> (wrapper.MyMethod()).
You can have 2 interfaces, one to implement and one for your service
contract.
The service contract will contain your standard method calls (i.e.
GetUsers, DeleteUser, etc.). The other contract will look something
like:
OnGetUsers.
Then in your service you would call:
Private SomeObject as IMyInternal = New MyInternalImplementation()
Public Function GetUsers as Users()
Try
IMyInternal.OnGetUsers
Catch Ex as Exception
End Try
Or maybe you can hook into ThreadException and globally catch errors?
--
spamhoneypot@rogers.com (Do not e-mail)
Re: WCF wrapping proxy calls to catch errors
by Tiago Halm on 12/5/2007 10:47:00 PM
If your main objective is to catch errors, and manage the generated fault
exception, then use an IErrorHandler, an implementation of this interface
will be the last bastion before the exception reaches WCF core.
Note: The Microsoft Enterprise Library uses this interface
See more here:
http://msdn2.microsoft.com/en-us/library/system.servicemodel.dispatcher.ierrorhandler.aspx
Tiago Halm