I have a simple service to return a custom SOAP Fault. And here is what the service throws
MappingError me = new MappingError();
me.ErrorCode =
ErrorType.OrderMappingFailed;me.Message = "Order mapping failed";
throw new FaultException<MappingError>(me);
At this point i get an exception "The creator of this fault did not specify a reason".
Looking around i see there is a FaultReason(String) class and FaultException<> has a readonly Reason property. So, i used one of the overloaded constructor to set the FaultReason and made it work. Here is the working code
MappingError me = new MappingError();me.ErrorCode =
ErrorType.OrderMappingFailed;me.Message =
"Order mapping failed"; FaultException<MappingError> fe = new FaultException<MappingError>(me, new FaultReason("Order Guid is NULL")); throw fe;Now, will this be the behaviour when Winfx ships. If that be the case please update the FaultException<> SDK docs.
[ServiceContract]
public interface IMyService
{
[
OperationContract][
FaultContract(typeof(MappingError))] Guid SendRequest(int ID);}
[
DataContract] public class MappingError{
[
DataMember] public ErrorType ErrorCode;[DataMember]
public String Message;
}

FaultException<MyType> : "The creator of this fault did not specify a reason" error
Dave Gurr
I guess then i don't understand the point in having a constructor like "new FaultException<MyType>(myinstance)" and a readonly Reason property.
It will be good just to have this constructor " new FaultException<MyType>(myinstance, FaultReason("Myreason"))"
Anyway, i posted the issue so that SDK docs http://windowssdk.msdn.microsoft.com/en-us/library/ms576199.aspx can be corrected.
Thanks,
T.Ramesh.
Michael_Shao