Tuesday, March 15, 2011

Interview Questions - Exception Handling in WCF


Click here for all SQL Server Interview Questions


Click here for all WCF Interview Questions


Click here for all ASP.NET Interview Questions


Click here for all C# Interview Questions


Click here for Written Test or practical ASP.NET Interview Questions asked in MNC's




What are SOAP Faults in WCF?
Common language runtime (CLR) exceptions do not flow across service boundaries. At the maximum, a CLR exceptions may propagate up to the service tier from business components. Unhandled CLR exceptions reach the service channel and are serialized as SOAP faults before reporting to clients. An unhandled CLR exception will fault the service channel, taking any existing sessions with it. That is why it is very importatnt to convert the CLR exceptions into SOAP faults. Where possible, throw fault exceptions


SOAP faults are standards based and interoperable. There are 2 formats used by SOAP faults, SOAP 1.1 and SOAP 1.2. SOAP format depends on the binding used.


What happens if there is an unhandled exception in WCF?
If there is an unhandled exception in WCF, the the service model returns a general SOAP fault, that does not include any exception specific details by default. However, you can include exception details in SOAP faults, using IncludeExceptionDetailsInFaults attribute. If IncludeExceptionDetailsInFaults is enabled, exception details including stack trace are included in the generated SOAP fault. IncludeExceptionDetailsInFaults should be enabled for debugging purposes only. Sending stack trace details is risky.




What are the 2 ways to enable IncludeExceptionDetailsInFaults for a WCF service?
Either programatically or thru configuration.


To enable thru code use ServiceBehaviorAttribute as shown below:
[ServiceBehaviourAttribute(IncludeExceptionDetailsInFaults=true)]
public class PragimService : IPragimService

To enable using configuration use servicedebug element as shown below



















Click here for all SQL Server Interview Questions


Click here for all WCF Interview Questions


Click here for all ASP.NET Interview Questions


Click here for all C# Interview Questions


Click here for Written Test or practical ASP.NET Interview Questions asked in MNC's

2 comments:

  1. Dear Sir,
    I saw the videos of c#, asp.net and sql and this videos helped me to clear my concepts.
    It would be glad if you add WCF videos also.

    Thanks

    ReplyDelete
  2. what is the difference between asp.net session and wcf session?

    ReplyDelete

If you are aware of any other WCF questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us