Windows Communication Foundation WCF Jim Fawcett CSE 775

  • Slides: 17
Download presentation
Windows Communication Foundation (WCF) Jim Fawcett CSE 775 – Distributed Objects Spring 2007

Windows Communication Foundation (WCF) Jim Fawcett CSE 775 – Distributed Objects Spring 2007

References n Introducing WCF, David Chappell, www. davidchappell. com/Introducing. WCFv 1. 2. 1. pdf

References n Introducing WCF, David Chappell, www. davidchappell. com/Introducing. WCFv 1. 2. 1. pdf – Using three diagrams from this reference n n Programming Indigo, David Pallmann, Microsoft Press, 2005 Pro WCF, Peiris and Mulder, Apress, 2007

What is WCF? n Integration of several Microsoft Technologies: – – Web services (ASMX)

What is WCF? n Integration of several Microsoft Technologies: – – Web services (ASMX) Web service extensions (WSE) n n n WS-Security WS-Reliability WS-Addressing –. Net Remoting – MSMQ messaging – COM+ Transactions

Chappell, ibid, pg 14

Chappell, ibid, pg 14

Channel Model n WCF supports three types of channel activity: – Asysnchronous one-way –

Channel Model n WCF supports three types of channel activity: – Asysnchronous one-way – Request, wait for reply – Full duplex two-way

Channel Shapes IOutput. Channel IInput. Channel IRequest. Channel IReply. Channel IDuplex. Channel

Channel Shapes IOutput. Channel IInput. Channel IRequest. Channel IReply. Channel IDuplex. Channel

Endpoints and Channels Service. Host host = new Service. Host(typeof(My. Service)); Uri address =

Endpoints and Channels Service. Host host = new Service. Host(typeof(My. Service)); Uri address = new Uri(“net. tcp: //kennyw 2/Service/endpoint”); Binding binding = new Net. Tcp. Binding(); Type contract = typeof(IMy. Contract); host. Add. Endpoint(address, binding, contract); host. Open();

Structure n Service – Contract n n n Service contract – RPC Interface Data

Structure n Service – Contract n n n Service contract – RPC Interface Data contract – Type serialization Message contract – Soap message – Binding n n Transport – HTTP, TCP, MSMQ, … Channel type – one-way, duplex, request-reply Encoding – XML, binary, MTOM (msg trans optim mech) WS-* protocols – WS-Security, … – Address n n n http: //some. URI net. tcp: //some. Other. URI net. msmq: //still. Another. URI

Chappell, ibid, pg 25

Chappell, ibid, pg 25

Channel Interfaces n public interface IOutput. Channel : IChannel { void Send(Message msg); }

Channel Interfaces n public interface IOutput. Channel : IChannel { void Send(Message msg); } n public interface IInput. Channel : IChannel { Message Receive(); } n public interface IDuplex. Channel : IOutput. Channel, IInput. Channel {} n public interface IRequest. Channel : IChannel { Message Request(Message msg); } n public interface IReply. Channel : IChannel { IRequest. Context Receive. Request(); } n public interface IRequest. Context : Idisposable { Message Request. Message { get; } void Reply(Message msg); }

Service Contract n <%@ Service. Host Language=“C#” Service=“My. Service” %> [Service. Contract] public interface

Service Contract n <%@ Service. Host Language=“C#” Service=“My. Service” %> [Service. Contract] public interface IMy. Service { [Operation. Contract] string Hello( string name); } public class My. Service : IMy. Service { public string Hello(string name) { return “Hello “ + name; } }

Hosts n WCF Services can be hosted in: – Internet Information Services (IIS) n

Hosts n WCF Services can be hosted in: – Internet Information Services (IIS) n Very similar to web services – Windows services n Exposing windows service in style of WS – Console and Winform applications n New style for socket like functionality

Monitoring Services n n Message Logging WCF Performance counters – – n Calls, Calls.

Monitoring Services n n Message Logging WCF Performance counters – – n Calls, Calls. Outsantding, Calls. Errored, … Security. Calls. Not. Authenticated, … Tx. Committed, Tx. Aborted, … RMSessions. Started, RMSessions. Faulted, … Windows Management Instrumentation (WMI), a COM technology

Other Topics n WCF Security – Credentials and claims (evidence) – Transport-level security –

Other Topics n WCF Security – Credentials and claims (evidence) – Transport-level security – Message-level security – Federated security model – Authorization – Auditing

Reliable Messaging n Reliable. Session enabled – – – Implemented at the SOAP level

Reliable Messaging n Reliable. Session enabled – – – Implemented at the SOAP level not TCP packet Very similar to TCP functionality Messages not sent are held in a Transfer Window cache – Will have problems with large messages n MSMQ Binding – Needs microsoft platforms on both ends – Supports store and forward

Other Features n WCF Supports transactions – ACID properties n Atomicity n Consistency n

Other Features n WCF Supports transactions – ACID properties n Atomicity n Consistency n Isolation n Durability – composite operations treated as a unit – Operations succeed or the system is returned to prior state – Each transaction is independent and isolated from other transactions – If an operation succeeds it becomes durable, e. g. , committed to a database or other persistant store

Conclusion n Convergence of programming models – Desktop Application – Web Application – Windows

Conclusion n Convergence of programming models – Desktop Application – Web Application – Windows Services Flexible hosting options n Flexible abstractions n