This is a modified version of the Microsoft sample code for
MessageInspecto r (InterceptingCh annelListener class) .
bool ProcessRequestC ontext(ref RequestContext requestContext)
{
if (requestContext == null)
{
return true;
}
Message m = requestContext. RequestMessage;
Message originalMessage = m;
try
{
this.OnReceive( ref m);
if (m != null || originalMessage == null)
{
requestContext = new InterceptingReq uestContext(thi s,
requestContext) ;
}
else
{
requestContext. Abort();
requestContext = null;
}
return requestContext != null;
}
catch (SomeException ax)
{
requestContext = new InterceptingReq uestContext(thi s,
requestContext) ;
FaultCode f = new FaultCode("ERR_ FAILED");
FaultException< CustomFaultfbex = new
FaultException< CustomFault>(ne w CustomFault("So meDetail"), ax.Message,
f);
MessageFault fault = fbex.CreateMess ageFault();
m = Message.CreateM essage(MessageV ersion.Soap12WS Addressing10,
fault, "http://www.w3.org/2005/08/addressing/fault");
requestContext. Reply(m);
return false;
}
}
In the catch block, I create a MessageFault and send that as a reply
using the RequestContext. The MessageFault created in this block
correctly encapsulates a FaultException< CustomFaultinst ance. On the
client side, it is converted to FaultException, with the Detail
stripped out.
Is there a configuration setting to change this behavior? Take note
that this is not an OperationContra ct since this code is executed
inside a BindingElementE xtentsionElemen t so marking the method with
FaultContractAt tribute doesn't work.
Any ideas?
MessageInspecto r (InterceptingCh annelListener class) .
bool ProcessRequestC ontext(ref RequestContext requestContext)
{
if (requestContext == null)
{
return true;
}
Message m = requestContext. RequestMessage;
Message originalMessage = m;
try
{
this.OnReceive( ref m);
if (m != null || originalMessage == null)
{
requestContext = new InterceptingReq uestContext(thi s,
requestContext) ;
}
else
{
requestContext. Abort();
requestContext = null;
}
return requestContext != null;
}
catch (SomeException ax)
{
requestContext = new InterceptingReq uestContext(thi s,
requestContext) ;
FaultCode f = new FaultCode("ERR_ FAILED");
FaultException< CustomFaultfbex = new
FaultException< CustomFault>(ne w CustomFault("So meDetail"), ax.Message,
f);
MessageFault fault = fbex.CreateMess ageFault();
m = Message.CreateM essage(MessageV ersion.Soap12WS Addressing10,
fault, "http://www.w3.org/2005/08/addressing/fault");
requestContext. Reply(m);
return false;
}
}
In the catch block, I create a MessageFault and send that as a reply
using the RequestContext. The MessageFault created in this block
correctly encapsulates a FaultException< CustomFaultinst ance. On the
client side, it is converted to FaultException, with the Detail
stripped out.
Is there a configuration setting to change this behavior? Take note
that this is not an OperationContra ct since this code is executed
inside a BindingElementE xtentsionElemen t so marking the method with
FaultContractAt tribute doesn't work.
Any ideas?