开发者

Modify the exception

I have 2 WCF services and a client which calls the method of 1st WCF service, and that method consequently calls the method of 2nd WCF service. The method of 2nd WCF service rises a generic fault exception, I need that this exception will be normally 'delivered' to my client through the 1st service. The 1st WCF service normally gets that generic exception with some Action "http://SomeNamespace" in exception message body. When the 1st service rethrow this exception to client, the client gets simple FaultException instead of FaultException1. I think the problem is inAction` which contains a namespace which is not acceptable for the client, and that's why the client is not able to get generic exception. There is a WCF Exception Shielding in 1st WCF service. Below are the configuration code and the handler code. Please help me and advise the best way to change the action of exception that the client will be able to get it normally.

Here is the config:

<exceptionHandling>
      <exceptionPolicies>
        <add name="WCF Exception Shielding">
          <exceptionTypes>
            <add type="System.ServiceModel.FaultException`1[[Sample.SomeFaultContract, Sample, PublicKeyToken=769e6b46280078d4]], System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                postHandlingAction="ThrowNewException" name="SomeFaultContract">
                <exceptionHandlers>
                  <add faultContractType="Sample.SomeFaultContract, Sample, PublicKeyToken=769e6b46280078d4"
                    type="Helper.ServiceFaultContractHandler, Logger, PublicKeyToken=769e6b46280078d4"
                    name="Fault Contract Exception Handler" />
                </exceptionHandlers>
            </add>
          </exceptionTypes>
        </add>
  </exceptionHandling>

And the handler part is:

public class ServiceFaultContractHandler : IExceptionHandler
{
   public ServiceFaultContractHandler(NameValueCollection ignore) { }

   public Exception HandleException(Exception exception, Guid correlationID)
   {


   }        
}

Thank you in adv开发者_C百科ance.

Aram


In order to get the details of the exception, you should set the includeExceptionDetailInFaults property to true in the service behavior.
Below is a sample:

<behaviors>
    <serviceBehaviors>
      <behavior name="WCFServicesName">
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
   </serviceBehaviors>
</behaviors>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜