Let's say you want that all your WCF proxy calls will come from one function. This could be very useful and save a lot of code.
For example you can write your proxy exception handling in one place.
Here is the code example that work on .NET framework 3.5 only:
// The public function that execute the WCF proxy call
public void WCFProxyCall()
{
CreateConferenceRequest r = new CreateConferenceRequest();
Func
proxy.CreateConference(a);
CreateConferenceResponse ci = ProxyWrapperOperation
}
// This is the single point function for the entire WCF proxy calls
// Here you can write code for all your WCF proxy calls.
private TResult ProxyWrapperOperation
{
TResult result;
try
{
result = operation(parameter);
}
catch (TimeoutException timeProblem)
{
proxy.Abort();
throw;
}
catch (FaultException unknownFault)
{
throw;
}
catch (CommunicationException commProblem)
{
proxy.Abort();
throw;
}
return result;
}
No comments:
Post a Comment