SlideShare a Scribd company logo
 
The Windows Communication Foundation
Interoperability & Integration Secure, Reliable, Transacted Messaging Decoupled, Dynamic Applications The Connectivity Imperative
.NET At The Core
Windows Communication Foundation The Unified Framework For Rapidly Building  Service-Oriented Applications
Windows Communication Foundation INTEROPERABILITY PRODUCTIVITY SERVICE-ORIENTED DEVELOPMENT Broad Support for WS-* specifications Compatible with existing MS distributed application technologies Unifies today’s distributed technologies Attribute-based development Visual Studio 2005 integration Enables development of loosely-coupled services Config-based communication
Unified Programming Model Interop with other platforms ASMX Attribute-  Based Programming Enterprise Services WS-* Protocol Support WSE Message- Oriented Programming System.Messaging Extensibility Location transparency .NET Remoting
WS-* Protocol Support XML Messaging Security Transactions Reliable Messaging Metadata
Investment Protection SIDE-BY-SIDE Interop UPGRADE
SERVICE ORIENTATION
From Objects to Services Polymorphism Encapsulation Subclassing Message-based Schema+Contract+Policy Broad Interop Location Transparent Tight Coupling Runtime Metadata Object-Oriented Service-Oriented Component-Oriented 1980s 2000s 1990s
Four Tenets of Service Orientation SERVICE ORIENTATION Compatibility Based On Policy Share Schema & Contract, Not Class Services Are Autonomous Boundaries Are Explicit
Conventional Web Services The old way of easily exposing components (ASMX): .NET Component ASMX Web Service HTTP Client
WCF Services The new way of easily exposing components (WCF): .NET Component HTTP Host TCP Host ICP Host MSMQ Host HTTP Client TCP Client ICP Client MSMQ Client Service Contract
The Windows Communication Foundation
Main Design Goal Unification Unify today’s distributed technology stacks Talk on-machine, cross-machine, cross-networks & Internet Productivity Codify best practices for building distributed apps Maximize productivity Integration Interoperate with apps running on other platforms Integrate with Microsoft’s existing technologies
Agenda Introduction Overview Main Concepts Hello World Contracts Bindings Behaviours Summary
Callers and Services Caller Service
Endpoints Caller Service Endpoint Endpoint Endpoint Endpoint
Address, Binding, Contract Service Caller C B A C B A A B C Address Where? Contract What? Binding How? C B A
Creating Endpoints Service Service Host Caller Proxy or ChannelFactory A B C C B A C B A C B A
Exposing & Configuring Endpoints proxy.cs Caller app/web.config GetMetadata WSDL Service ? C B A C B A C B A C B A C B A C B A
Hello World
Agenda Introduction Overview Contracts Service Data Message Bindings Behaviours Instancing Summary
WCF Contracts Overview Service Contracts Describe the operations a service can perform Map CLR types to WSDL Data Contracts Describes a data structure Maps CLR types to XSD Message Contracts Defines the structure of the message on the wire Maps CLR types to SOAP messages
Service Contract [ServiceContract] public interface ICalculator { [OperationContract] int DoMath(int a, int b, string op); }
Service Contract An Opt-In Model [ServiceContract] public interface ICalculator { [OperationContract] int DoMath(int a, int b, string op); // Not exposed as part of the external contract :-) void MethodRequiredForImplementation(bool b); }
Operations Types Message  DoXmlMath( Message  m); Untyped (“Universal”) MathResponse  DoMsgMath( MathRequest  msg); int  DoParamsMath( int a, int b, string op ); Typed Message Parameterized Operations (shorthand for TM)
Service Contract: Names [ServiceContract( Namespace ="http://TechEd.WCF.Intro")] public interface IGreetings { [OperationContract(  Name =“SayHello", Action ="http://TechEd.WCF.Intro/HelloRequest", ReplyAction ="http://TechEd.WCF.Intro/HelloResponse")] string Greet(string name); [OperationContractAttribute( Action = "*" )] void UnrecognizedMessageHandler( Message msg ); } class GreetingService : IGreetings { public string Greet(string name) { return “Hello, " + name; } public void UnrecognizedMessageHandler(Message msg) { Console.WriteLine("Unrecognized message: " + msg.ToString()); } }
Modeling Request/Reply Operations On the wire everything is asynchronous Therefore, Request and Reply correlation can be modeled in 2 ways It can be modeled either as a synchronous (blocking) method call or using the .NET Async-Pattern The implementation on the client and the service can be  different ! [OperationContract] MathResponse DoMsgMath(MathRequest msg); [OperationContrac t(AsyncPattern=true) ] IAsyncResult BeginDoMsgMath(MathRequest msg,  AsyncCallback cb, object state ) ; MathResponse EndDoMsgMath(IAsyncResult call);
Service Contract: OneWay [ServiceContract] public interface IOneWayCalculator { [OperationContract( IsOneWay=true )] void DoMath(MathRequest request); }
Service Contract: Duplex [ServiceContract(SessionMode=SessionMode.Required,  CallbackContract=typeof(ICalculator Results ) ] public interface ICalculatorProblems { [OperationContract(IsOneWay=true)] void DoMath(MathRequest request); } public interface ICalculatorResults { [OperationContract(IsOneWay=true)] void DisplayResults(MathResponse response); }
Service Contract: Faults t ry { return n1 / n2; } catch (DivideByZeroException e)   { MyMathFault f = new MyMathFault (n1, n2); FaultReason r = new FaultReason(&quot;Divide By Zero&quot;); throw new Fault Exception < MyMathFault >( f, r ); } [ServiceContract(Session=true)] public interface ICalculator { [OperationContract] [FaultContract(typeof( MyMathFault ))] int DoMath(int a, int b, string op); }
Service Contract: Versioning [ServiceContract] public interface  ICalculator2 : ICalculator { [OperationContract(IsOneWay=true)] void SolveAndStoreProblem (ComplexProblem p); }
Service Contract: Streams [ServiceContract ] public interface IStreamCalculator { [OperationContract] Stream  Fibonacci(int iterations); }
Data Contract [DataContract] public enum Position { [ EnumMember ] Employee, [ EnumMember ] Manager, [ EnumMember( Value =  “ Vendor&quot; ) ] Contractor, NotASerializableEnumeration }
Data Contract: Names [DataContract( Name=“Complex”,   Namespace=“http://BigMath.Samples” )] public class ComplexNumber { [DataMember( Name=“RealPart” )]    public double Real = 0.0D;   [DataMember( Name=“ImaginaryPart” )]   public double Imaginary = 0.0D;   public ComplexNumber(double r, double i)   {   this.Real = r;   this.Imaginary = i;   } }
Data Contract: Enumerations [DataContract] public enum Position { [EnumMember] Employee, [EnumMember] Manager, [EnumMember(Value = “Vendor&quot;)] Contractor, NotASerializableEnumeration }
Message Contract [MessageContract] public class ComplexProblem { [MessageHeader(Name=&quot;Op&quot;, MustUnderstand=true)]    public string operation; [MessageBodyMember]   public ComplexNumber n1; [MessageBodyMember]   public ComplexNumber n2; [MessageBodyMember]   public ComplexNumber solution;   // Constructors… }
Mapping Contracts (1/2) [ MessageContract ] public class MyRequest { [MessageHeader]  public int Amount; [MessageBody]   public ItemInfo Info; } [ DataContract ] public class ItemInfo { [DataMember]  public int ID; [DataMember]  public double Cost; [DataMember]  public string Name; } wsdl:message wsdl:part xsd:element
Mapping Contracts (2/2) [ ServiceContract ] public interface MyContract { [OperationContract]   MyReply MyOp(MyRequest request); [OperationContract]   void MyOp2(MyRequest2 request); } wsdl:portType wsdl:operation
Agenda Introduction Overview Contracts Bindings Behaviours Summary
Bindings & Binding Elements Transport IPC MSMQ Custom TCP HTTP Protocol Encoders .NET TX Custom Security Reliability Binding HTTP TX Security Reliability Text Text Binary Custom TCP Binary
Binding Element Features Transport selection TCP, HTTP, Named Pipes, P2P, MSMQ, Custom Transport level security, Streaming Encoding Text, Binary, MTOM, Custom End-to-end Security Confidentiality, integrity, authN, authZ, Federation Credentials: X509, User/Pwd, Kerberos, SAML, InfoCard , Custom End-to-end Reliable messaging Transport independent QoS (in order, exactly once) Volatile and durable queues Transactions Shared transactions for “synchronous” operations Transactional queues for “asynchronous” operations [Your own feature goes here]
System-Provided Bindings N = None | T = Transport | M = Message | B = Both | RS = Reliable Sessions Binding  Interop Security Session TX Duplex  BasicHttpBinding  BP 1.1 N, T N N n/a WSHttpBinding  WS M , T, X N , T, RS N , Yes n/a WSDualHttpBinding  WS M RS N , Yes Yes WSFederationBinding  Federation M N , RS N , Yes No NetTcpBinding  .NET T , M T  ,RS N , Yes Yes NetNamedPipeBinding  .NET T T , N N , Yes Yes NetPeerTcpBinding  Peer T N N Yes NetMsmqBinding  .NET T , M, X N N , Yes No MsmqIntegrationBinding  MSMQ T N N , Yes n/a
Binding in Config <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?> <configuration> <system.serviceModel> <services> <service serviceType=&quot;CalculatorService&quot;> <endpoint address=&quot;Calculator&quot; bindingSectionName=&quot;basicProfileBinding&quot; contractType=&quot;ICalculator&quot; /> </service> </services> </system.serviceModel> </configuration>
Configuring Bindings <endpoint address=&quot;Calculator&quot;   bindingSectionName=&quot; basic Http Binding &quot;   bindingConfiguration=&quot; UsernameBinding &quot;   contractType=&quot;ICalculator&quot; /> <bindings>   <basicHttpBinding> <binding name=&quot; UsernameBinding &quot;  messageEncoding=&quot;Mtom&quot;> <security mode=&quot;Message&quot;> <message clientCredentialType=&quot;UserName&quot;/> </security> </binding> </basicHttpBinding> < /bindings>
Custom Bindings <bindings> <customBinding> <customBinding> <binding name=&quot;ReliableTCP&quot;> <reliableSession   inactivityTimeout=&quot;0:0:5“ ordered=&quot;true&quot;/> <binaryMessageEncoding/> <tcpTransport transferMode=&quot;Buffered&quot;/> </binding> </customBinding> </customBinding> </bindings>
Choosing Bindings Any Protocol Any Binding Any Binding WCF WCF MSMQ WCF COM+/ES WCF MSMQ Protocol WS-* Protocols MSMQ Binding Moniker ASMX/WSE3 WCF WS-* Protocols Http/WS Binding Other Platform WCF WS-* Protocols Http/WS Binding
Interaction of Bindings and Code Bindings provide features that affect code Session Duplex Ordered Delivery Transaction Flow Queued Delivery Attribute capture the code’s requirements Infrastructure ensures that all the bindings satisfy these requirements
Agenda Introduction Overview Contracts Bindings Behaviours Summary
Behaviors Client-Side  Behaviors Service-Side Behaviors Service Caller Be Be C B A C B A A B C C B A
Behaviors: Overview Behaviors are all local Developers care about some behaviors Concurrency, instancing model, … Everything that affects the correctness of the service Deployers care about other behaviors Throttling, Metadata exposure, message routing info, … Everything that has to do with the service’s runtime aspects Anything you can do in config, you can do in code Code is King – you can always override the config settings
Example: Security Service Client Be Be Bindings Move Claims in Messages Behaviors Implement Security Gates Behaviors Provide Credentials C B A C B A A B C C B A
Example: Transactions Service Caller Be Bindings Flow Transactions Behaviors AutoEnlist and AutoComplete C B A C B A A B C C B A
Anti-Example: Reliable Sessions Service Caller Bindings provide Session and Guarantees C B A C B A A B C C B A
Behavior Features Operation timeouts (close, open, idle) Concurrency, Instancing, Thread-Binding Throttling Faults, Exceptions Impersonation, Authorization, Auditing AutoEnlist, AutoComplete, Timeout, Isolation Serialization, MustUnderstand Metadata More…
Features Summary Address Binding Behavior Contract HTTP Transport TCP Transport NamedPipe Transport MSMQ Transport Custom Transport WS-Security Protocol WS-RM Protocol WS-AT Protocol Duplex Channel Custom Protocol http://... net.tcp://... net.pipe://... net.msmq://... xxx://... Throttling Behavior Metadata Behavior Error  Behavior Custom Behavior Instancing Behavior Concurrency Behavior Transaction Behavior Security Behavior Request/ Response One-Way Duplex net.p2p://... Peer Transport Externally visible, per-endpoint Opaque, per-service, endpoint, or op
WCF Application “Architecture” Channels Transport Channels   (IPC, HTTP, TCP…) Reliability Message  Encoder Security Hosting Environments WAS IIS .exe Windows Service DllHost Messaging Services Queuing Routing Eventing Discovery Service Model Application Instance  Manager Context  Manager Type Integration Service Methods Declarative Behaviors Transacted Methods
Presentation Takeaways WCF is the future of distributed computing It combines the best of all existing Microsoft distributed computing stacks It uses WS-* standards for interoperability and .NET value-add for performance and integration with existing solutions WCF is available for Windows Vista, Windows XP SP2, Windows Server 2003 Download WCF Today! http://www.NetFx3.com/   Presentation code at ShyCohen.com
 

More Related Content

What's hot (20)

PPTX
Windows Communication Foundation (WCF)
Betclic Everest Group Tech Team
 
PDF
Building RESTful Services with WCF 4.0
Saltmarch Media
 
PDF
Windows Communication Foundation (WCF)
Peter R. Egli
 
PPT
Wcf architecture overview
Arbind Tiwari
 
PPTX
WCF Fundamentals
Safaa Farouk
 
PPTX
WCF Introduction
Mohamed Zakarya Abdelgawad
 
PPT
WCF
Vishwa Mohan
 
PPT
WCF
Duy Do Phan
 
PPTX
Introduction to WCF
ybbest
 
PPTX
WCF for begineers
Dhananjay Kumar
 
PPTX
Windows Communication Foundation (WCF) Best Practices
Orbit One - We create coherence
 
PPTX
Windows Communication Foundation (WCF) Service
Sj Lim
 
PPT
Session 1: The SOAP Story
ukdpe
 
PPTX
1. WCF Services - Exam 70-487
Bat Programmer
 
PPT
Service Oriented Development With Windows Communication Foundation 2003
Jason Townsend, MBA
 
PPT
Web services, WCF services and Multi Threading with Windows Forms
Peter Gfader
 
PPTX
Web services
aspnet123
 
PPT
Overview of Windows Vista Devices and Windows Communication Foundation (WCF)
Jorgen Thelin
 
PPTX
Web Services - Architecture and SOAP (part 1)
Martin Necasky
 
Windows Communication Foundation (WCF)
Betclic Everest Group Tech Team
 
Building RESTful Services with WCF 4.0
Saltmarch Media
 
Windows Communication Foundation (WCF)
Peter R. Egli
 
Wcf architecture overview
Arbind Tiwari
 
WCF Fundamentals
Safaa Farouk
 
WCF Introduction
Mohamed Zakarya Abdelgawad
 
Introduction to WCF
ybbest
 
WCF for begineers
Dhananjay Kumar
 
Windows Communication Foundation (WCF) Best Practices
Orbit One - We create coherence
 
Windows Communication Foundation (WCF) Service
Sj Lim
 
Session 1: The SOAP Story
ukdpe
 
1. WCF Services - Exam 70-487
Bat Programmer
 
Service Oriented Development With Windows Communication Foundation 2003
Jason Townsend, MBA
 
Web services, WCF services and Multi Threading with Windows Forms
Peter Gfader
 
Web services
aspnet123
 
Overview of Windows Vista Devices and Windows Communication Foundation (WCF)
Jorgen Thelin
 
Web Services - Architecture and SOAP (part 1)
Martin Necasky
 

Viewers also liked (9)

PPTX
Windows Communication Foundation
Tunku Abdul Rahman College
 
PPTX
Message oriented middleware
Coforge (Erstwhile WHISHWORKS)
 
PDF
MSMQ - Microsoft Message Queueing
Peter R. Egli
 
PPT
Message Oriented Middleware (MOM)
drewenut
 
PPTX
Message Oriented Architecture using NServiceBus
Lars-Erik Kindblad
 
PPT
Architecture of message oriented middleware
Likan Patra
 
PDF
Middleware and Middleware in distributed application
Rishikese MR
 
PDF
MOM - Message Oriented Middleware
Peter R. Egli
 
DOC
Unit 1 architecture of distributed systems
karan2190
 
Windows Communication Foundation
Tunku Abdul Rahman College
 
Message oriented middleware
Coforge (Erstwhile WHISHWORKS)
 
MSMQ - Microsoft Message Queueing
Peter R. Egli
 
Message Oriented Middleware (MOM)
drewenut
 
Message Oriented Architecture using NServiceBus
Lars-Erik Kindblad
 
Architecture of message oriented middleware
Likan Patra
 
Middleware and Middleware in distributed application
Rishikese MR
 
MOM - Message Oriented Middleware
Peter R. Egli
 
Unit 1 architecture of distributed systems
karan2190
 
Ad

Similar to introduction to Windows Comunication Foundation (20)

PPTX
WCF - In a Week
gnanaarunganesh
 
PPT
WCF 4.0
Eyal Vardi
 
PPT
Tulsa Tech Fest2008 Service Oriented Development With Windows Communication F...
Jason Townsend, MBA
 
PPT
Service Oriented Development With Windows Communication Foundation Tulsa Dnug
Jason Townsend, MBA
 
PDF
Wcf faq
Rajoo Jha
 
PPT
Dot Net Training Wcf Dot Net35
Subodh Pushpak
 
PDF
Wcf difference faqs-1
Umar Ali
 
PPTX
Windows Communication Foundation
Vijay Krishna Parasi
 
PPTX
WCF 4 Overview
Mariano Omar Rodriguez
 
PPTX
A presentation on WCF & REST
Santhu Rao
 
PPS
WCF (Windows Communication Foundation_Unit_01)
Prashanth Shivakumar
 
PPT
WCF and WF in Framework 3.5
ukdpe
 
PPT
Windows Communication Foundation
David Truxall
 
DOC
WCF tutorial
Abhi Arya
 
PPT
WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt
yatakonakiran2
 
PDF
WCF Interview Questions By Scholarhat PDF
Scholarhat
 
PPTX
Complete Architecture and Development Guide To Windows Communication Foundati...
Abdul Khan
 
ODP
What is in a Good Contract? Designing Interfaces for Distributed Systems
Schalk Cronjé
 
DOCX
Top wcf interview questions
tongdang
 
PPTX
Wcf for the web developer
Codecamp Romania
 
WCF - In a Week
gnanaarunganesh
 
WCF 4.0
Eyal Vardi
 
Tulsa Tech Fest2008 Service Oriented Development With Windows Communication F...
Jason Townsend, MBA
 
Service Oriented Development With Windows Communication Foundation Tulsa Dnug
Jason Townsend, MBA
 
Wcf faq
Rajoo Jha
 
Dot Net Training Wcf Dot Net35
Subodh Pushpak
 
Wcf difference faqs-1
Umar Ali
 
Windows Communication Foundation
Vijay Krishna Parasi
 
WCF 4 Overview
Mariano Omar Rodriguez
 
A presentation on WCF & REST
Santhu Rao
 
WCF (Windows Communication Foundation_Unit_01)
Prashanth Shivakumar
 
WCF and WF in Framework 3.5
ukdpe
 
Windows Communication Foundation
David Truxall
 
WCF tutorial
Abhi Arya
 
WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt
yatakonakiran2
 
WCF Interview Questions By Scholarhat PDF
Scholarhat
 
Complete Architecture and Development Guide To Windows Communication Foundati...
Abdul Khan
 
What is in a Good Contract? Designing Interfaces for Distributed Systems
Schalk Cronjé
 
Top wcf interview questions
tongdang
 
Wcf for the web developer
Codecamp Romania
 
Ad

Recently uploaded (20)

PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 

introduction to Windows Comunication Foundation

  • 1.  
  • 3. Interoperability & Integration Secure, Reliable, Transacted Messaging Decoupled, Dynamic Applications The Connectivity Imperative
  • 4. .NET At The Core
  • 5. Windows Communication Foundation The Unified Framework For Rapidly Building Service-Oriented Applications
  • 6. Windows Communication Foundation INTEROPERABILITY PRODUCTIVITY SERVICE-ORIENTED DEVELOPMENT Broad Support for WS-* specifications Compatible with existing MS distributed application technologies Unifies today’s distributed technologies Attribute-based development Visual Studio 2005 integration Enables development of loosely-coupled services Config-based communication
  • 7. Unified Programming Model Interop with other platforms ASMX Attribute- Based Programming Enterprise Services WS-* Protocol Support WSE Message- Oriented Programming System.Messaging Extensibility Location transparency .NET Remoting
  • 8. WS-* Protocol Support XML Messaging Security Transactions Reliable Messaging Metadata
  • 11. From Objects to Services Polymorphism Encapsulation Subclassing Message-based Schema+Contract+Policy Broad Interop Location Transparent Tight Coupling Runtime Metadata Object-Oriented Service-Oriented Component-Oriented 1980s 2000s 1990s
  • 12. Four Tenets of Service Orientation SERVICE ORIENTATION Compatibility Based On Policy Share Schema & Contract, Not Class Services Are Autonomous Boundaries Are Explicit
  • 13. Conventional Web Services The old way of easily exposing components (ASMX): .NET Component ASMX Web Service HTTP Client
  • 14. WCF Services The new way of easily exposing components (WCF): .NET Component HTTP Host TCP Host ICP Host MSMQ Host HTTP Client TCP Client ICP Client MSMQ Client Service Contract
  • 16. Main Design Goal Unification Unify today’s distributed technology stacks Talk on-machine, cross-machine, cross-networks & Internet Productivity Codify best practices for building distributed apps Maximize productivity Integration Interoperate with apps running on other platforms Integrate with Microsoft’s existing technologies
  • 17. Agenda Introduction Overview Main Concepts Hello World Contracts Bindings Behaviours Summary
  • 18. Callers and Services Caller Service
  • 19. Endpoints Caller Service Endpoint Endpoint Endpoint Endpoint
  • 20. Address, Binding, Contract Service Caller C B A C B A A B C Address Where? Contract What? Binding How? C B A
  • 21. Creating Endpoints Service Service Host Caller Proxy or ChannelFactory A B C C B A C B A C B A
  • 22. Exposing & Configuring Endpoints proxy.cs Caller app/web.config GetMetadata WSDL Service ? C B A C B A C B A C B A C B A C B A
  • 24. Agenda Introduction Overview Contracts Service Data Message Bindings Behaviours Instancing Summary
  • 25. WCF Contracts Overview Service Contracts Describe the operations a service can perform Map CLR types to WSDL Data Contracts Describes a data structure Maps CLR types to XSD Message Contracts Defines the structure of the message on the wire Maps CLR types to SOAP messages
  • 26. Service Contract [ServiceContract] public interface ICalculator { [OperationContract] int DoMath(int a, int b, string op); }
  • 27. Service Contract An Opt-In Model [ServiceContract] public interface ICalculator { [OperationContract] int DoMath(int a, int b, string op); // Not exposed as part of the external contract :-) void MethodRequiredForImplementation(bool b); }
  • 28. Operations Types Message DoXmlMath( Message m); Untyped (“Universal”) MathResponse DoMsgMath( MathRequest msg); int DoParamsMath( int a, int b, string op ); Typed Message Parameterized Operations (shorthand for TM)
  • 29. Service Contract: Names [ServiceContract( Namespace =&quot;http://TechEd.WCF.Intro&quot;)] public interface IGreetings { [OperationContract( Name =“SayHello&quot;, Action =&quot;http://TechEd.WCF.Intro/HelloRequest&quot;, ReplyAction =&quot;http://TechEd.WCF.Intro/HelloResponse&quot;)] string Greet(string name); [OperationContractAttribute( Action = &quot;*&quot; )] void UnrecognizedMessageHandler( Message msg ); } class GreetingService : IGreetings { public string Greet(string name) { return “Hello, &quot; + name; } public void UnrecognizedMessageHandler(Message msg) { Console.WriteLine(&quot;Unrecognized message: &quot; + msg.ToString()); } }
  • 30. Modeling Request/Reply Operations On the wire everything is asynchronous Therefore, Request and Reply correlation can be modeled in 2 ways It can be modeled either as a synchronous (blocking) method call or using the .NET Async-Pattern The implementation on the client and the service can be different ! [OperationContract] MathResponse DoMsgMath(MathRequest msg); [OperationContrac t(AsyncPattern=true) ] IAsyncResult BeginDoMsgMath(MathRequest msg, AsyncCallback cb, object state ) ; MathResponse EndDoMsgMath(IAsyncResult call);
  • 31. Service Contract: OneWay [ServiceContract] public interface IOneWayCalculator { [OperationContract( IsOneWay=true )] void DoMath(MathRequest request); }
  • 32. Service Contract: Duplex [ServiceContract(SessionMode=SessionMode.Required, CallbackContract=typeof(ICalculator Results ) ] public interface ICalculatorProblems { [OperationContract(IsOneWay=true)] void DoMath(MathRequest request); } public interface ICalculatorResults { [OperationContract(IsOneWay=true)] void DisplayResults(MathResponse response); }
  • 33. Service Contract: Faults t ry { return n1 / n2; } catch (DivideByZeroException e) { MyMathFault f = new MyMathFault (n1, n2); FaultReason r = new FaultReason(&quot;Divide By Zero&quot;); throw new Fault Exception < MyMathFault >( f, r ); } [ServiceContract(Session=true)] public interface ICalculator { [OperationContract] [FaultContract(typeof( MyMathFault ))] int DoMath(int a, int b, string op); }
  • 34. Service Contract: Versioning [ServiceContract] public interface ICalculator2 : ICalculator { [OperationContract(IsOneWay=true)] void SolveAndStoreProblem (ComplexProblem p); }
  • 35. Service Contract: Streams [ServiceContract ] public interface IStreamCalculator { [OperationContract] Stream Fibonacci(int iterations); }
  • 36. Data Contract [DataContract] public enum Position { [ EnumMember ] Employee, [ EnumMember ] Manager, [ EnumMember( Value = “ Vendor&quot; ) ] Contractor, NotASerializableEnumeration }
  • 37. Data Contract: Names [DataContract( Name=“Complex”, Namespace=“http://BigMath.Samples” )] public class ComplexNumber { [DataMember( Name=“RealPart” )] public double Real = 0.0D; [DataMember( Name=“ImaginaryPart” )] public double Imaginary = 0.0D; public ComplexNumber(double r, double i) { this.Real = r; this.Imaginary = i; } }
  • 38. Data Contract: Enumerations [DataContract] public enum Position { [EnumMember] Employee, [EnumMember] Manager, [EnumMember(Value = “Vendor&quot;)] Contractor, NotASerializableEnumeration }
  • 39. Message Contract [MessageContract] public class ComplexProblem { [MessageHeader(Name=&quot;Op&quot;, MustUnderstand=true)] public string operation; [MessageBodyMember] public ComplexNumber n1; [MessageBodyMember] public ComplexNumber n2; [MessageBodyMember] public ComplexNumber solution; // Constructors… }
  • 40. Mapping Contracts (1/2) [ MessageContract ] public class MyRequest { [MessageHeader] public int Amount; [MessageBody] public ItemInfo Info; } [ DataContract ] public class ItemInfo { [DataMember] public int ID; [DataMember] public double Cost; [DataMember] public string Name; } wsdl:message wsdl:part xsd:element
  • 41. Mapping Contracts (2/2) [ ServiceContract ] public interface MyContract { [OperationContract] MyReply MyOp(MyRequest request); [OperationContract] void MyOp2(MyRequest2 request); } wsdl:portType wsdl:operation
  • 42. Agenda Introduction Overview Contracts Bindings Behaviours Summary
  • 43. Bindings & Binding Elements Transport IPC MSMQ Custom TCP HTTP Protocol Encoders .NET TX Custom Security Reliability Binding HTTP TX Security Reliability Text Text Binary Custom TCP Binary
  • 44. Binding Element Features Transport selection TCP, HTTP, Named Pipes, P2P, MSMQ, Custom Transport level security, Streaming Encoding Text, Binary, MTOM, Custom End-to-end Security Confidentiality, integrity, authN, authZ, Federation Credentials: X509, User/Pwd, Kerberos, SAML, InfoCard , Custom End-to-end Reliable messaging Transport independent QoS (in order, exactly once) Volatile and durable queues Transactions Shared transactions for “synchronous” operations Transactional queues for “asynchronous” operations [Your own feature goes here]
  • 45. System-Provided Bindings N = None | T = Transport | M = Message | B = Both | RS = Reliable Sessions Binding Interop Security Session TX Duplex BasicHttpBinding BP 1.1 N, T N N n/a WSHttpBinding WS M , T, X N , T, RS N , Yes n/a WSDualHttpBinding WS M RS N , Yes Yes WSFederationBinding Federation M N , RS N , Yes No NetTcpBinding .NET T , M T ,RS N , Yes Yes NetNamedPipeBinding .NET T T , N N , Yes Yes NetPeerTcpBinding Peer T N N Yes NetMsmqBinding .NET T , M, X N N , Yes No MsmqIntegrationBinding MSMQ T N N , Yes n/a
  • 46. Binding in Config <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?> <configuration> <system.serviceModel> <services> <service serviceType=&quot;CalculatorService&quot;> <endpoint address=&quot;Calculator&quot; bindingSectionName=&quot;basicProfileBinding&quot; contractType=&quot;ICalculator&quot; /> </service> </services> </system.serviceModel> </configuration>
  • 47. Configuring Bindings <endpoint address=&quot;Calculator&quot; bindingSectionName=&quot; basic Http Binding &quot; bindingConfiguration=&quot; UsernameBinding &quot; contractType=&quot;ICalculator&quot; /> <bindings> <basicHttpBinding> <binding name=&quot; UsernameBinding &quot; messageEncoding=&quot;Mtom&quot;> <security mode=&quot;Message&quot;> <message clientCredentialType=&quot;UserName&quot;/> </security> </binding> </basicHttpBinding> < /bindings>
  • 48. Custom Bindings <bindings> <customBinding> <customBinding> <binding name=&quot;ReliableTCP&quot;> <reliableSession inactivityTimeout=&quot;0:0:5“ ordered=&quot;true&quot;/> <binaryMessageEncoding/> <tcpTransport transferMode=&quot;Buffered&quot;/> </binding> </customBinding> </customBinding> </bindings>
  • 49. Choosing Bindings Any Protocol Any Binding Any Binding WCF WCF MSMQ WCF COM+/ES WCF MSMQ Protocol WS-* Protocols MSMQ Binding Moniker ASMX/WSE3 WCF WS-* Protocols Http/WS Binding Other Platform WCF WS-* Protocols Http/WS Binding
  • 50. Interaction of Bindings and Code Bindings provide features that affect code Session Duplex Ordered Delivery Transaction Flow Queued Delivery Attribute capture the code’s requirements Infrastructure ensures that all the bindings satisfy these requirements
  • 51. Agenda Introduction Overview Contracts Bindings Behaviours Summary
  • 52. Behaviors Client-Side Behaviors Service-Side Behaviors Service Caller Be Be C B A C B A A B C C B A
  • 53. Behaviors: Overview Behaviors are all local Developers care about some behaviors Concurrency, instancing model, … Everything that affects the correctness of the service Deployers care about other behaviors Throttling, Metadata exposure, message routing info, … Everything that has to do with the service’s runtime aspects Anything you can do in config, you can do in code Code is King – you can always override the config settings
  • 54. Example: Security Service Client Be Be Bindings Move Claims in Messages Behaviors Implement Security Gates Behaviors Provide Credentials C B A C B A A B C C B A
  • 55. Example: Transactions Service Caller Be Bindings Flow Transactions Behaviors AutoEnlist and AutoComplete C B A C B A A B C C B A
  • 56. Anti-Example: Reliable Sessions Service Caller Bindings provide Session and Guarantees C B A C B A A B C C B A
  • 57. Behavior Features Operation timeouts (close, open, idle) Concurrency, Instancing, Thread-Binding Throttling Faults, Exceptions Impersonation, Authorization, Auditing AutoEnlist, AutoComplete, Timeout, Isolation Serialization, MustUnderstand Metadata More…
  • 58. Features Summary Address Binding Behavior Contract HTTP Transport TCP Transport NamedPipe Transport MSMQ Transport Custom Transport WS-Security Protocol WS-RM Protocol WS-AT Protocol Duplex Channel Custom Protocol http://... net.tcp://... net.pipe://... net.msmq://... xxx://... Throttling Behavior Metadata Behavior Error Behavior Custom Behavior Instancing Behavior Concurrency Behavior Transaction Behavior Security Behavior Request/ Response One-Way Duplex net.p2p://... Peer Transport Externally visible, per-endpoint Opaque, per-service, endpoint, or op
  • 59. WCF Application “Architecture” Channels Transport Channels (IPC, HTTP, TCP…) Reliability Message Encoder Security Hosting Environments WAS IIS .exe Windows Service DllHost Messaging Services Queuing Routing Eventing Discovery Service Model Application Instance Manager Context Manager Type Integration Service Methods Declarative Behaviors Transacted Methods
  • 60. Presentation Takeaways WCF is the future of distributed computing It combines the best of all existing Microsoft distributed computing stacks It uses WS-* standards for interoperability and .NET value-add for performance and integration with existing solutions WCF is available for Windows Vista, Windows XP SP2, Windows Server 2003 Download WCF Today! http://www.NetFx3.com/ Presentation code at ShyCohen.com
  • 61.