Diving Into Services

Post on 10-Jun-2015

850 views 0 download

description

WCF Presentation for the St Louis .NET User Group - May 2009

Transcript of Diving Into Services

Diving Into Services With WCFChris Deweese

Announcements / Contact Chris•Twitter: @cdeweese•Web: http://christopherDeweese.com•From IL? See me about an IL Metro .NET

Users Group•St Louis Day of .NET August 28-29

@Ameristar in St Charles

Agenda

•Part 1 – WCF Basics▫What & Why of WCF▫Key Concepts▫WCF Architecture▫ABCs of WCF▫Code! And Demo

•Part 2 – Advanced WCF▫Business Case▫Architecture▫Code! And Demo

What is WCF

•Framework for building service-oriented applications

•Separates the logic of services from the channels they communicate on

•Messages based on Simple Object Access Protocol (SOAP)

•Support for REST & Plain-old Xml (POX) as of .NET 3.5

Why WCF

•Evolution of service oriented thinking•Remoting, Message Queuing, and ASMX

were designed on different stacks•WCF unifies the programming model for

exposing services through different channels (Web, Message Queues, TCP)▫Service logic and function is not dependent

on the channel or transport

Key WCF Concepts•Service – Unit of work exposed to the world.•Endpoint – the collection of the services address,

binding, and contract.•Binding – How you interact with the service at the

wire level.•Channel – Picks the message up from the wire

format and brings it into the WCF stack.•Dispatcher – Manages execution of service code

by routing messages to the appropriate service instance and method.

•Behavior – How you can control the local execution of a service.

Hosting WCF Services

•In Process•Windows Service•Web Service (IIS)•Windows Activation Services

▫WAS allows you to host a service on any binding

WCF Architecture

Address

•“Dude where’s my service?”•The location of the service on the network

where it can be reached.▫http://localhost/wantedperson/v1/

wanted.svc▫net.msmq://localhost/private/

wantedpersonv1▫net.tcp://localhost:6000/wantedpersonv1

•Set via configuration or through code

Binding• “How do I talk to this thing?”• The protocol and policies used to connect to the

service at it’s address.• WCF Provided Bindings

▫Http(BasicHttp, WsHttp, WsDualHttp, WsFederation)▫NetMsmq▫MsmqIntegration▫NetNamedPipe▫NetTcp▫NetPeerTcp

• Set via configuration or through code

Contract

•“What’s it going to do for me?”•Defines the operations, inputs, outputs,

and message exchange patterns of the service.

•Defined using an Interface; wired into WCF by using the ServiceContract attribute. Methods use the OperationContract attribute. Classes use the DataContract attribute and members use the DataMember attribute.

•WCF Serialization is “Opt-In”

WCF Basics – Demo and Code!

Photo by szeke: http://www.flickr.com/photos/pedrosz/

Part II: Advanced WCF

Concepts Demonstrated

•Tracing•Fault Contracts•Multiple Endpoints•Custom Service Host•Custom Service Behavior

▫Unity Integration for Inversion of Control▫Unity Lifetime Manager (Singleton)

•Service Instancing Behavior•Enterprise Library Exception Handling

Integration

WCF Advanced – Demo and Code!

Questions?