Question

How can a WCF CommunicationObject transition to a faulted state: I created a WCF library in Visual Studio, deployed it into IIS, inside it i have two methods:

    public string GetData(int value)
    {
        throw new FaultException(value.ToString());
    }

    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
        throw new TestException();
    }

From the client, i simply call these two methods over and over again, however, the CommunicationObjectFaultedException is not thrown at any time.

I read in an article WCF error handling and some best practices that non-FaultExceptions are converted by default "automatically" to a FaultException. If this is right, then when and how does the WCF client's communication object become in a faulted state?

One other thing, does anybody know any MSDN reference that confirms that FaultException is the best way to make sure the WCF communication object does not transition into Faulted state.

Was it helpful?

Solution

The channel will be on a faulted state if you are using a session (i.e. a binding that supports session) and a call to a method raises an exception that is not handled.

Another way you can get into a faulted state is the session timing out while the channel is open.

It is the channel that is in a faulted state, not the service

Understanding State Changes in WCF

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top