No matter how nice and orderly my WCF service is about throwing exceptions:
throw new FaultException<SapphireServiceFault>(fault, new FaultReason(fault.Message))
They always wind up in the client handler as "400 - Bad Request". If you walk the chain of InnerException, it leads to one 400-BadRequest and then null. No mention of the FaultException.
My interface is decorated with the FaultContract attribute:
[WebInvoke(Method = "POST", UriTemplate = "action/execute/{actionID}")]
[OperationContract]
[FaultContract(typeof(SapphireServiceFault))]
void ExecuteActionGroup(string actionID);
The implementation of that interface just throws the Fault for testing:
public void ExecuteActionGroup(string groupID)
{
SapphireServiceFault fault = new SapphireServiceFault("Bad Mojo");
throw new FaultException<SapphireServiceFault>(fault, new FaultReason("Hello World"));
...
}
In the client, I can even try to catch that specific exception, but it comes through at a 400, not a FaultException:
try
{
Program.SapphireService.ExecuteActionGroup(actionGroup.ActionGroupName);
}
catch(FaultException<SapphireServiceFault> ex)
{
// Does not catch anything
MessageBoxEx.Show("Failed to execute action: " + ex.Message);
}
There must be something I'm overlooking!
As I am using programmatic binding I cannot add anything to the app.config, but anything that can be done there can usually be done in the bindings. For what it is worth, I have IncludeExceptionDetailInFaults turned on.
What am I missing to get more meaningful results back to the client?