Servicehost Customization

Preview:

DESCRIPTION

There’s no doubt that building a distributed system with WCF is much easier than with any other Microsoft technology. But, how can we be sure that we are doing it the right way? In this session we will go over common scenarios developer face when building and hosting WCF services: 1. Error handling 2. Serialization issue 3. Choocing the instanse model 4. Extendable object and see how widening the WCF ServiceHost in the infrastructure level can help us to build a robust, reliable and manageable system.

Citation preview

Building a ServiceHost for your WCF Services - the Right Way!

Eyal VardiCEO Experts4DMicrosoft VSTO MVPblog: www.eVardi.com

AgendaAgenda

Service Description

Service Pipeline

Serialization issue

Extensible Object Pattern

Error Handler

Q&A

Summary

ConsultinConsultingg

MentorinMentoringg

ProjectsProjects

Service Description Service Description (Metadata)(Metadata)

It describe all aspects of the service, endpoints & behaviors ( A, B, C, Be )

new ServiceHost( typeof(Hello) )

ServiceServiceDescriptioDescriptio

nn

ConfigConfig

Service HostService Host

ServiceService

InterfacesInterfaces

CodeCode

Service Model Service Model LayerLayer

Message LayerMessage LayerWSDLWSDL

Configuration Manager for Configuration Manager for WCFWCF

Application LauncherApplication Launcher

ServiceHosServiceHostt

ServiceHosServiceHostt

ServiceHosServiceHostt

IdId IdId IdId

Config ManagerConfig ManagerConfig ManagerConfig Manager

ServiceHost(Service Description)

Inside WCF Pipeline Inside WCF Pipeline (Receiver)(Receiver)

Message Message LayerLayer

Service Model LayerService Model Layer

ServiceServiceDescriptioDescriptio

nnBehaviorBehaviorss

ServiceService

Service HostService Host

Channel Channel DispatcherDispatcher

EndpointEndpoint Dispatcher Dispatcher

DispatchDispatchRuntimeRuntime

DispatchDispatchOperatioOperatio

nn

Service Service DescriptionDescription

EndpointEndpoint

ContractContract

BindingBinding

OperatioOperationn

MessaMessagege

IIServiceServiceBehaviorBehavior

IIEndpointEndpointBehaviorBehavior

IIContractContractBehaviorBehavior

IIOpertionOpertionBehaviorBehavior

How to manipulate the How to manipulate the pipelinepipeline

WCF Behavior ClassesWCF Behavior Classes WCF have built-in WCF have built-in attributeattribute and and

configuration element configuration element to to customize the pipeline.customize the pipeline.

ServiceService

WCF Pipeline Configuration WCF Pipeline Configuration OptionsOptions

CDCD

EDED

EDED

DRDR

DRDR

DODO

DODO

DODO

DODO

ServiceThrottle ErrorHandlers Endpoints Timeouts

ServiceThrottle ErrorHandlers Endpoints Timeouts

Address Filter Contract Filter

Address Filter Contract Filter

MethodMethodMethodMethod

MethodMethodMethodMethod

MethodMethodMethodMethod

MethodMethodMethodMethod

CContractontract BeBehaviorshaviors

Message Behavior Instance Behavior Security Behavior

Message Behavior Instance Behavior Security Behavior

Formatter Parameter Inspector Invoker

Formatter Parameter Inspector Invoker

Error Handling ExtensionsError Handling Extensions

ServiceThrottle ErrorHandlers Endpoints Timeouts

ServiceThrottle ErrorHandlers Endpoints Timeouts

Error Handler

CCDD EDED DD

RRDDOO

Error Error HandlersHandlers

Error Error HandlersHandlers

The Extensible Object The Extensible Object PatternPattern Extend existing runtime classes with:

New functionality New state to an object

Persistence State in Persistence State in ServiceService

Persistence State in Persistence State in ServiceService

SerivceSerivceSerivceSerivceSerivceSerivce

Instance ContextInstance Context

Service HostService Host

ExtenstioExtenstionn

ExtenstioExtenstionn

Extensible Object

CCDD EDED DD

RRDDOO

Extensible Extensible ObjectObject

Extensible Extensible ObjectObject

Instance PoolInstance Pool

Instance Pool

CCDD EDED DD

RRDDOO

Instance PoolInstance PoolInstance PoolInstance Pool

Serialization IssueSerialization Issue

public UserInfoUserInfo EchoUser ( int userIduserId );

EncodingEncoding

DeserializationDeserializationSerializationSerialization

EncodingEncodingBin

din

Bin

din

ggTra

nsp

oTra

nsp

ortrt

DispatchOperation.FormattDispatchOperation.Formatter er

Type coupled coupled Loosely coupledcoupled Known Type Known Type IExtensibleDataObject

DeserializeRequestDeserializeRequest

SerializeReplySerializeReply

OO Formatter

CCDD EDED DD

RRDDOO

FormatterFormatterFormatterFormatter

Serialization issue ExampleSerialization issue Example

ConsumeConsumerr

infrastructureinfrastructure

ProviderProvider

OO Formatter

CCDD EDED DD

RRDDOO

OO FormatterOO FormatterOO FormatterOO Formatter

SummaSummaryry Service Description

Service Pipeline

Serialization issue

The Extensible Object Pattern

Error Handler

ResourcesResources

www.Experts4D.com / Eyal www.NetFX3.com http://code.msdn.com/wcfvisualizer

Recommended