Feb 8, 2012 at 12:19 PM
Edited Feb 8, 2012 at 12:35 PM
I’m going to implement exception handling on our wcf services using exception shielding. Today the operation contracts are not decorated by a FaultContract attribute, nor is the implementation of service contract
interface decorated by a ExceptionShielding attribute.
Our service is already in use by numerous customers, so I cannot change the contract/wsdl easily and force our customers to update the service reference.
I created a small project to test if WcfExceptionShielding will break the contract/change the wsdl. The service have one method.
public decimal Devide(decimal number1, decimal number2)
No faultcontracts are added, to simulate the existence of our service to day.
Added one client.
Updated the service with ExceptionShielding attribute, created a FaultContract, added faultcontract attribute to the operation contract.
Created a second client.
Both client have the same code, with the exception of the first catch.
static void Main(string args)
using (var client = new TestService.TestServiceClient())
var result = client.Devide(1, 0);
//client2 have catch (FaultException<TestService.MyFaultContract> ex)
catch (FaultException ex)
catch (Exception ex)
The results. Client 2 catches the MyFaultContract that shields the DivideByZeroException.
Client 1 catches a MessageSecurityException “No signature message parts were specified for messages with the 'http://tempuri.org/ITestService/DevideMyFaultContractFault' action.”. Clearly the deserialization
failure of the faultcontract raised by the wcf exception shielding.
So the million dollar question is, how can I apply WCF Exception shielding to an existing wcf service without updating the clients?