diving into services

21
Diving Into Services With WCF Chris Deweese

Upload: chris-deweese

Post on 10-Jun-2015

851 views

Category:

Technology


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Diving Into Services

Diving Into Services With WCFChris Deweese

Page 2: Diving Into Services

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

Page 3: Diving Into Services

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

Page 4: Diving Into Services

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

Page 5: Diving Into Services

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

Page 6: Diving Into Services

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.

Page 7: Diving Into Services

Hosting WCF Services

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

▫WAS allows you to host a service on any binding

Page 8: Diving Into Services

WCF Architecture

Page 9: Diving Into Services
Page 10: Diving Into Services
Page 11: Diving Into Services
Page 13: Diving Into Services

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

Page 14: Diving Into Services

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

Page 15: Diving Into Services

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”

Page 16: Diving Into Services

WCF Basics – Demo and Code!

Page 17: Diving Into Services

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

Page 18: Diving Into Services

Part II: Advanced WCF

Page 19: Diving Into Services

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

Page 20: Diving Into Services

WCF Advanced – Demo and Code!

Page 21: Diving Into Services

Questions?