all groups > dotnet web services > december 2007 >
You're in the

dotnet web services

group:

WCF wrapping proxy calls to catch errors



WCF wrapping proxy calls to catch errors Kike
12/4/2007 10:00:05 AM
dotnet web services: 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()).


Any way of wrapping proxy calls transparentrly? Any ideas on how to do this?

Many Thanks.

Re: WCF wrapping proxy calls to catch errors Spam Catcher
12/5/2007 8:46:08 AM
=?Utf-8?B?S2lrZQ==?= <Kike@discussions.microsoft.com> wrote in
news:985239CD-8EE8-4631-8A19-53AB79D32F11@microsoft.com:

[quoted text, click to view]


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?

--
Re: WCF wrapping proxy calls to catch errors Tiago Halm
12/5/2007 10:47:17 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

AddThis Social Bookmark Button