slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
virtual techdays PowerPoint Presentation
Download Presentation
virtual techdays

Loading in 2 Seconds...

play fullscreen
1 / 25

virtual techdays - PowerPoint PPT Presentation


  • 210 Views
  • Uploaded on

INDIA │ 22-24 November 2010. virtual techdays. Exception Handling in WCF. Jebarson Jebamony │ Consultant, Microsoft. INDIA │ 22-24 November 2010. virtual techdays. Introduction Exceptions and handling. Exception handling in WCF vs WS. Exception handling in WCF & guidelines.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'virtual techdays' - iolani


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

INDIA │ 22-24 November2010

virtual techdays

Exception Handling in WCF

Jebarson Jebamony│ Consultant, Microsoft

slide2

INDIA │ 22-24 November2010

virtual techdays

  • Introduction
    • Exceptions and handling.
    • Exception handling in WCF vs WS.
    • Exception handling in WCF & guidelines.
  • Fault Exceptions
    • Using FaultException, FaultReason and FaultCode.
    • Strong custom type fault exceptions.
  • Custom Error Handler
    • Using IErrorHandler
  • Questions & Answers

S E S S I O N A G E N D A

slide3

INDIA │ 22-24 November2010

virtual techdays

Exception Handling in WCF

Introduction

slide4

INDIA │ 22-24 November2010

virtual techdays

  • Exceptions are inevitable.
  • Exception handling should be included by design.
  • The more the exception handling, the more the robust.
  • Crash recovery for unhandled exceptions.
  • Testing applications against exceptions.

Introduction

Exceptions and handling

slide5

INDIA │ 22-24 November2010

virtual techdays

DEMO : Exception Handling In WCF

Application Overview

slide6

INDIA │ 22-24 November2010

virtual techdays

Demo : Application Overview

High Level Diagram

Proxy

slide7

INDIA │ 22-24 November2010

virtual techdays

  • WS can never return the exception stack trace to the caller.
  • Custom code has to be written to return the exception.
  • All the exceptions will be returned as Fault in WCF.

Introduction

Exception handling in WCF vs. WS.

slide8

INDIA │ 22-24 November2010

virtual techdays

Contd..

Introduction

Exception handling in WCF vs. WS.

slide9

INDIA │ 22-24 November2010

virtual techdays

DEMO: Exception Handling In WCF

GetUser│Default exception handling

slide10

INDIA │ 22-24 November2010

virtual techdays

What happened on Demo?

Introduction

Exception handling in WCF & guidelines

slide11

INDIA │ 22-24 November2010

virtual techdays

Exception Handling in WCF

Fault Exceptions

slide12

INDIA │ 22-24 November2010

virtual techdays

Fault Exceptions

Architecture

slide13

INDIA │ 22-24 November2010

virtual techdays

  • FaultCode

Fault Code

Differentiates the fault from other; “Name” is used as a differentiator.

“SubCode” is used to denote the inner fault code or exception.

Static method “CreateReceiverFaultCode” is used to create a fault code when the fault occurred because of the reciever (server).

Static method “CreateSenderFaultCode” is used to create a fault code when the fault occurred because of the sender (client).

Flags are available to differentiate if the fault is of receiver / sender / pre-defined.

Fault Exceptions

FaultCode

slide14

INDIA │ 22-24 November2010

virtual techdays

  • FaultReason

Fault Reason

Used as a type to notify the reason for the fault occurance.

There can be a single / multiple reason text (“FaultReasonText”) provided.

Multi cultural text can be added to the reason and provides the support to bind the text to the UI with respect to the culture set on the UI.

Fault Exceptions

FaultReason

slide15

INDIA │ 22-24 November2010

virtual techdays

DEMO: Exception Handling In WCF

GetUser│Fault Exception handling guidelines & scenarios

slide16

INDIA │ 22-24 November2010

virtual techdays

What happened on Demo?

Fault Exceptions

Using FaultException

slide17

INDIA │ 22-24 November2010

virtual techdays

  • Remember to switch on “includeExceptionDetailInFaults” while debugging.
  • Also remember to switch off “includeExceptionDetailInFaults” on production. All exceptions should be converted to faults while on production.
  • Ensure that the faults / exceptions are called in the reverse inheritance order to ensure that exceptions are caught on the right catch block.

Fault Exceptions

Points to remember

slide18

INDIA │ 22-24 November2010

virtual techdays

  • CustomType

FaultException<T>

Allows to define and pass a custom data contract type to the fault exception.

Inherits from FaultException and therefore has to be caught before the base is caught.

Requires the types expected to be defined in the operation contract. If not defined, the custom exception will be considered as “FaultException”.

Note: Remember as of now the MSDN shows that the reason is not mandatory for you to raise a FaultException<T>, which is incorrect.

Fault Exceptions

Strong custom type fault exceptions.

slide19

INDIA │ 22-24 November2010

virtual techdays

DEMO: Exception Handling In WCF

GetUser│Custom fault exception handling

slide20

INDIA │ 22-24 November2010

virtual techdays

Exception Handling in WCF

Custom Error Handler

slide21

INDIA │ 22-24 November2010

virtual techdays

  • Allows one to dictate the way the exception has to be handled when it raises.
  • Gives the service programmer less control over the way the exception is bubbled.
  • “ProvideFault” is the method which allows to raise the fault message with your own freedom. The logic on which fault to be raised is done here.
  • “HandleError” is mostly used for logging the exceptions and writing failure recovery mechanism. The programmer can return a flag stating whether to crash the session or continue.
  • Custom error handler needs an behavior extension defined to provide control to it for a needed service.

Custom Error Handler

Using IErrorHandler

slide22

INDIA │ 22-24 November2010

virtual techdays

Custom Error Handler

Using IErrorHandler

slide23

INDIA │ 22-24 November2010

virtual techdays

DEMO: Exception Handling In WCF

GetUser│Custom error handler

slide24

INDIA │ 22-24 November2010

virtual techdays

Exception Handling In WCF

Questions & Answers

slide25

THANKS│22-24 November2010

virtual techdays

jebarv@microsoft.com │ http://jebarson.info