SlideShare a Scribd company logo
Windows Communication
Foundation
Jim Fawcett
CSE681 – SW Modeling & Analysis
Summer 2008
References
• Programming “INDIGO”, David Pallmann, Microsoft Press, 2005
• Windows Communication Foundation Unleashed, McMurtry, Mercuri,
Watling, Winkler, SAMS, 2007
• Pro WCF, Peiris and Mulder, apress, 2007
• MSDN WCF Root Page
• WCF Feature Details
• Distributed .NET Learn ABCs Of Programming WCF
• Service Station Serialization in Windows Communication Foundation
• Service Station WCF Messaging Fundamentals
• Windows Communication Foundation Glossary
• Windows Communication Foundation Tools
2
References – Activation & Channels
• How to Access WCF Services with One-Way and Request-Reply Contracts
• How to Access Services with a Duplex Contract
• Sessions, Instancing, and Concurrency
• WCF Essentials Instance Management
• WCF Essentials One-Way Calls, Callbacks, Events
References – Web Model
• How to Create a Basic Web-Style Service
• WCF Web Programming Model Overview
• Web Programming Model
• WCF Web Programming Object Model
• WCF Syndication HTTP Programming with WCF and the .NET Framework
3.5
• Creating WCF AJAX Services without ASP.NET
• Creating WCF Services for ASP.NET AJAX
References – Odds and Ends
• Accessing Services Using a Client
• Clients
• Client Architecture
• Client Configuration
• Call WCF Service Operations Asynchronously
• A Performance Comparison
• Security in WCF
What is WCF?
• Provides software services on machines, networks,
and across the internet
• Unified programming model for all of these
• Supported natively on Windows Vista
– Requires installation on XP
• Not available on other platforms
– Mono?
– DotGnu?
– Mac OSX ?
6
Integration into .Net 3
• One model for distributed systems decomposes into
presentation layer, application logic layer, and data
layer, all bound together with communication.
• Presentation: WPF, Silverlight with Asp.Net
• Data: LINQ - binds views to storage
• Communic: WCF – local, network, internet
• Applic. Logic: Custom designs
7
WCF Design Principles
• Boundaries are explicit
– No attempt to hide communication
• Services are autonomous
– Deployed, managed, and versioned independently
• Services share contracts and schemas, not types
– Contracts define behavior, schemas define data
• Compatibility is policy-based
– Policy supports separation of behavior from access
constraints
8
Essential Pieces of WCF
• Contracts for services, data, and messages
– A contract is simply an interface declaration
• Service, Data, and Message definitions
– Class implementations
• Configurations defined programmatically or
declaratively
– config files.
• A host process (can be self hosted)
– IIS, Windows Executable, Windows Service, or WAS
• .Net Framework (3.5) Classes provide support for all
of the above.
9
Look and Feel of WCF
• Convergence of programming models
– Just like web services
– Similar to .Net Remoting
– Sockets on steriods
– Hosting for local, network, and web
• Communication models
– Remote Procedure Call (RPC) with optional data models
– Message passing
– One way, request and wait for reply, asynchronous full
duplex
10
WCF Architecture
11
ServiceModel Namespace
• Bindings, Channels, Endpoints, Messages,
Serialization
• Activation, Concurrency, Hosting, Security,
Sessions
• Queuing, Transactions
• Exceptions
12
Principle Parts of a WCF Service
• Contract
– An interface defining services rendered
– Service, Data, Message
• Endpoints
– Address: http://localhost/Calculator/service
– Binding: wsHttpBinding
– Contract: ICalculator
• Implementation
– One or more classes that implement the contract
interfaces. May also include hosting code.
13
WCF Service Files
• IService.cs
– Interface(s) that define a service, data, or message
contract
• Service.cs
– Implement the service’s functionality
• Service.svc
– Markup file (with one line) used for services hosted in IIS
• Configuration files that declare service attributes,
endpoints, and policy
– App.config (self hosted) contains service model markup
– Web.config (hosted in IIS) has web server policy markup
plus service model markup, as in App.config
14
Service serviceModel Markup
• <system.serviceModel>
<services>
<service name=“mySvcName” behaviorConfiguration=“…”>
<endpoint address=“” binding=“wsHttpBinding”
contract=“myNamespace.myInterface” />
<!-- can expose additional endpoints here -->
<endpoint address=“mex” binding=“mexHttpBinding”
contract=“IMetadataExchange” />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name=“myNamespace.mySvcNameBehavior”>
<serviceMetaData httpGetEnabled=“true” />
<serviceDebug includeExceptionDetailInFaults=“false” />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
15
Channels
• Channels are the vehicles that transport
messages. They provide:
– Transport protocols via bindings
• Http, wsHttp, Tcp, MSMQ, named pipes
– Encoding and Encryption
– Reliable sessions
– Communication modes
• Simplex, duplex, send and wait
– Security modes
16
WCF Bindings
17
Binding Interoperability Mode of Security (Default) Session (Default) Transactions Duplex
BasicHttpBinding Basic Profile 1.1
(None), Transport, Message,
Mixed
None, (None) (None) n/a
WSHttpBinding WS
None, Transport, (Message),
Mixed
(None), Transport, Reliable
Session
(None), Yes n/a
WS2007HttpBinding
WS-Security, WS-Trust,
WS-SecureConversation,
WS-SecurityPolicy
None, Transport, (Message),
Mixed
(None), Transport, Reliable
Session
(None), Yes n/a
WSDualHttpBinding WS None, (Message) (Reliable Session) (None), Yes Yes
WSFederationHttpBinding WS-Federation None, (Message), Mixed (None), Reliable Session (None), Yes No
WS2007FederationHttpBinding WS-Federation None, (Message), Mixed (None), Reliable Session (None), Yes No
NetTcpBinding .NET
None, (Transport), Message,
Mixed
Reliable Session, (Transport) (None), Yes Yes
NetNamedPipeBinding .NET
None,
(Transport)
None, (Transport) (None), Yes Yes
NetMsmqBinding .NET
None, Message, (Transport),
Both
(None) (None), Yes No
NetPeerTcpBinding Peer
None, Message, (Transport),
Mixed
(None) (None) Yes
MsmqIntegrationBinding MSMQ None, (Transport) (None) (None), Yes n/a
Interoperability
• Channel protocols determine interoperability with
other platforms:
– BasicHttpBinding  universal interoperability
– wsHttpBinding  platforms that use ws extensions
– netTcpBinding  .Net on both ends
– MSMQ  WCF to pre WCF windows platforms
18
Hosting
• Self Host
– Service has a Main entry point, runs in its own
process.
• Internet Information Server (IIS)
– BasicHttpBinding provides a web service.
– wsHttpBinding provides web service with ws*
extensions.
• Windows Activation Service (WAS)
– Uses virtual directory, like web service.
19
Service Behaviors
• Instancing:
– Singleton: one instance for all clients
– Per call: one instance per service call
– Private session: one instance per client session
– Shared session: one instance per session shared between
clients
• Concurrency models for instances:
– Single: one thread at a time accesses instance
– Multiple: more than one thread may enter instance
– Reentrant: threads make recursive calls without deadlock
20
Other Service Behaviors
• Throttling:
– Limits on number of messages, instances, and threads a service can
process simultaneously
• Error handling:
– Options to handle, let framework handle, and report to client
• Metadata:
– Services can be self-describing, providing MEX endpoints
• Lifetime:
– Can specify session duration, service operations to initiate sessions
and others to terminate sessions
• Security:
– Can specify message confidentiality, integrity, authentication,
authorization, auditing, and replay detection.
21
Structuring Service Code
Service Class Attribute
Service contract interface [ServiceContract]
Service operation method [OperationContract]
Implementation class [ServiceBehavior]
Derive from contract interface
Implementation method [OperationBehavior]
Data Contract class [DataContract] class
[DataMember] member
Message Contract interface [MessageContract] interface
[MessageHeader] member
[MessageBody] member
22
Building Clients
• Build proxy with svcutil
– Visual Studio will do that if you add a service or
web reference
– Proxy code is in a subdirectory under the project.
• Add proxy code to project
• Add “using System.ServiceModel” to client
code
• Build and run
23
Generating Proxies
• SvcUtil.exe generates code:
– from a mex endpoint:
svcutil http://localhost/myService
– from WSDL or XSD files:
svcutil myService.wsdl
• SvcUtil.exe generates WSDL and XSD files from
a service library:
– svcutil myService.dll
24
Channel Model
• You can create a channel programmatically
– In this case you access the channel directly
without the need of a proxy.
• All of the configuration normally done with a
Web.config or App.config can also be done
programmatically.
25
Types of WCF Contracts
• WCF supports:
– Service contracts
• Supports RPCs with native data types
– Data contracts
• Data contracts provide definitions of user defined data
structures for transmission through RPCs
– Message contracts
• Message contracts support message passing
• Instead of calling functions send and receive messages
26
27
WCF Samples
• Microsoft has provided a large set of very interesting
samples:
– WCF Samples home:
http://msdn.microsoft.com/en-us/library/ms751514.aspx
– Setup instructions here:
http://msdn.microsoft.com/en-us/library/ms751402.aspx
– Download here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=0043041F-95D6-4EB7-
966A-C21A737E193A&displaylang=en
– Note:
• Samples use a single virtual directory, created by the setup process
• Builds clear the virtual directory and copy built sample files
• Initial setup installs developer certificate, required to run SSL
• In Vista, must Run Visual Studio as administrator
28
White Papers
• The following two white papers, by David
Chappell plus the Microsoft samples are a
great help learning WCF.
– www.davidchappell.com/articles/white_papers/Introducing_WCF_in_.
Net_Framework_3.5_v1.0.docx
– www.davidchappell.com/articles/white_papers/WCF_Diversity_v1.0.d
ocx
29
End of Presentation
30

More Related Content

PPTX
Micro services
PDF
Wcf v1-day1
PPTX
Windows Communication Foundation (WCF)
PPTX
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
PDF
Week2 cloud computing week2
PPTX
nptl cc video.pptx
PPTX
The Hitchhiker’s Guide to Hybrid Connectivity
PPT
Session 1 Shanon Richards-Exposing Data Using WCF
Micro services
Wcf v1-day1
Windows Communication Foundation (WCF)
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Week2 cloud computing week2
nptl cc video.pptx
The Hitchhiker’s Guide to Hybrid Connectivity
Session 1 Shanon Richards-Exposing Data Using WCF

Similar to DotNet_WindowsCommunicationFoundation.ppt (20)

PDF
Cert05 70-487 - developing microsoft azure and web services
PDF
Making Rational HATS a Strategic Investment
DOC
WCF tutorial
PPT
web services-May 25.ppt
PPTX
Complete Architecture and Development Guide To Windows Communication Foundati...
PPT
WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt
PPTX
Windows 8 Metro apps and the outside world
PPTX
Sudheer d socalcodecamp_10_16_2011
PDF
Introduction to SOAP/WSDL Web Services and RESTful Web Services
PPSX
Welcome to Web Services
PPTX
Hybrid Solution Integration
PDF
Wcf remaining
PPT
PDF
WSO2Con USA 2017: Implement an Effective Digital Platform Using WSO2 Integration
PPTX
Exploring microservices in a Microsoft landscape
PPT
PDF
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
PDF
Java Web Services [1/5]: Introduction to Web Services
PPT
webservicearchitecture-150614164814-lva1-app6892.ppt
PPTX
Cloud description
Cert05 70-487 - developing microsoft azure and web services
Making Rational HATS a Strategic Investment
WCF tutorial
web services-May 25.ppt
Complete Architecture and Development Guide To Windows Communication Foundati...
WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt
Windows 8 Metro apps and the outside world
Sudheer d socalcodecamp_10_16_2011
Introduction to SOAP/WSDL Web Services and RESTful Web Services
Welcome to Web Services
Hybrid Solution Integration
Wcf remaining
WSO2Con USA 2017: Implement an Effective Digital Platform Using WSO2 Integration
Exploring microservices in a Microsoft landscape
MS TechDays 2011 - How to Run Middleware in the Cloud Story of Windows Azure ...
Java Web Services [1/5]: Introduction to Web Services
webservicearchitecture-150614164814-lva1-app6892.ppt
Cloud description
Ad

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Digital Strategies for Manufacturing Companies
PDF
Nekopoi APK 2025 free lastest update
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Transform Your Business with a Software ERP System
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
medical staffing services at VALiNTRY
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
ai tools demonstartion for schools and inter college
Introduction Database Management System for Course Database
Which alternative to Crystal Reports is best for small or large businesses.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Digital Strategies for Manufacturing Companies
Nekopoi APK 2025 free lastest update
Softaken Excel to vCard Converter Software.pdf
Online Work Permit System for Fast Permit Processing
Internet Downloader Manager (IDM) Crack 6.42 Build 41
How to Choose the Right IT Partner for Your Business in Malaysia
Odoo POS Development Services by CandidRoot Solutions
Transform Your Business with a Software ERP System
Adobe Illustrator 28.6 Crack My Vision of Vector Design
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
medical staffing services at VALiNTRY
PTS Company Brochure 2025 (1).pdf.......
ai tools demonstartion for schools and inter college
Ad

DotNet_WindowsCommunicationFoundation.ppt

  • 1. Windows Communication Foundation Jim Fawcett CSE681 – SW Modeling & Analysis Summer 2008
  • 2. References • Programming “INDIGO”, David Pallmann, Microsoft Press, 2005 • Windows Communication Foundation Unleashed, McMurtry, Mercuri, Watling, Winkler, SAMS, 2007 • Pro WCF, Peiris and Mulder, apress, 2007 • MSDN WCF Root Page • WCF Feature Details • Distributed .NET Learn ABCs Of Programming WCF • Service Station Serialization in Windows Communication Foundation • Service Station WCF Messaging Fundamentals • Windows Communication Foundation Glossary • Windows Communication Foundation Tools 2
  • 3. References – Activation & Channels • How to Access WCF Services with One-Way and Request-Reply Contracts • How to Access Services with a Duplex Contract • Sessions, Instancing, and Concurrency • WCF Essentials Instance Management • WCF Essentials One-Way Calls, Callbacks, Events
  • 4. References – Web Model • How to Create a Basic Web-Style Service • WCF Web Programming Model Overview • Web Programming Model • WCF Web Programming Object Model • WCF Syndication HTTP Programming with WCF and the .NET Framework 3.5 • Creating WCF AJAX Services without ASP.NET • Creating WCF Services for ASP.NET AJAX
  • 5. References – Odds and Ends • Accessing Services Using a Client • Clients • Client Architecture • Client Configuration • Call WCF Service Operations Asynchronously • A Performance Comparison • Security in WCF
  • 6. What is WCF? • Provides software services on machines, networks, and across the internet • Unified programming model for all of these • Supported natively on Windows Vista – Requires installation on XP • Not available on other platforms – Mono? – DotGnu? – Mac OSX ? 6
  • 7. Integration into .Net 3 • One model for distributed systems decomposes into presentation layer, application logic layer, and data layer, all bound together with communication. • Presentation: WPF, Silverlight with Asp.Net • Data: LINQ - binds views to storage • Communic: WCF – local, network, internet • Applic. Logic: Custom designs 7
  • 8. WCF Design Principles • Boundaries are explicit – No attempt to hide communication • Services are autonomous – Deployed, managed, and versioned independently • Services share contracts and schemas, not types – Contracts define behavior, schemas define data • Compatibility is policy-based – Policy supports separation of behavior from access constraints 8
  • 9. Essential Pieces of WCF • Contracts for services, data, and messages – A contract is simply an interface declaration • Service, Data, and Message definitions – Class implementations • Configurations defined programmatically or declaratively – config files. • A host process (can be self hosted) – IIS, Windows Executable, Windows Service, or WAS • .Net Framework (3.5) Classes provide support for all of the above. 9
  • 10. Look and Feel of WCF • Convergence of programming models – Just like web services – Similar to .Net Remoting – Sockets on steriods – Hosting for local, network, and web • Communication models – Remote Procedure Call (RPC) with optional data models – Message passing – One way, request and wait for reply, asynchronous full duplex 10
  • 12. ServiceModel Namespace • Bindings, Channels, Endpoints, Messages, Serialization • Activation, Concurrency, Hosting, Security, Sessions • Queuing, Transactions • Exceptions 12
  • 13. Principle Parts of a WCF Service • Contract – An interface defining services rendered – Service, Data, Message • Endpoints – Address: http://localhost/Calculator/service – Binding: wsHttpBinding – Contract: ICalculator • Implementation – One or more classes that implement the contract interfaces. May also include hosting code. 13
  • 14. WCF Service Files • IService.cs – Interface(s) that define a service, data, or message contract • Service.cs – Implement the service’s functionality • Service.svc – Markup file (with one line) used for services hosted in IIS • Configuration files that declare service attributes, endpoints, and policy – App.config (self hosted) contains service model markup – Web.config (hosted in IIS) has web server policy markup plus service model markup, as in App.config 14
  • 15. Service serviceModel Markup • <system.serviceModel> <services> <service name=“mySvcName” behaviorConfiguration=“…”> <endpoint address=“” binding=“wsHttpBinding” contract=“myNamespace.myInterface” /> <!-- can expose additional endpoints here --> <endpoint address=“mex” binding=“mexHttpBinding” contract=“IMetadataExchange” /> </service> </services> <behaviors> <serviceBehaviors> <behavior name=“myNamespace.mySvcNameBehavior”> <serviceMetaData httpGetEnabled=“true” /> <serviceDebug includeExceptionDetailInFaults=“false” /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> 15
  • 16. Channels • Channels are the vehicles that transport messages. They provide: – Transport protocols via bindings • Http, wsHttp, Tcp, MSMQ, named pipes – Encoding and Encryption – Reliable sessions – Communication modes • Simplex, duplex, send and wait – Security modes 16
  • 17. WCF Bindings 17 Binding Interoperability Mode of Security (Default) Session (Default) Transactions Duplex BasicHttpBinding Basic Profile 1.1 (None), Transport, Message, Mixed None, (None) (None) n/a WSHttpBinding WS None, Transport, (Message), Mixed (None), Transport, Reliable Session (None), Yes n/a WS2007HttpBinding WS-Security, WS-Trust, WS-SecureConversation, WS-SecurityPolicy None, Transport, (Message), Mixed (None), Transport, Reliable Session (None), Yes n/a WSDualHttpBinding WS None, (Message) (Reliable Session) (None), Yes Yes WSFederationHttpBinding WS-Federation None, (Message), Mixed (None), Reliable Session (None), Yes No WS2007FederationHttpBinding WS-Federation None, (Message), Mixed (None), Reliable Session (None), Yes No NetTcpBinding .NET None, (Transport), Message, Mixed Reliable Session, (Transport) (None), Yes Yes NetNamedPipeBinding .NET None, (Transport) None, (Transport) (None), Yes Yes NetMsmqBinding .NET None, Message, (Transport), Both (None) (None), Yes No NetPeerTcpBinding Peer None, Message, (Transport), Mixed (None) (None) Yes MsmqIntegrationBinding MSMQ None, (Transport) (None) (None), Yes n/a
  • 18. Interoperability • Channel protocols determine interoperability with other platforms: – BasicHttpBinding  universal interoperability – wsHttpBinding  platforms that use ws extensions – netTcpBinding  .Net on both ends – MSMQ  WCF to pre WCF windows platforms 18
  • 19. Hosting • Self Host – Service has a Main entry point, runs in its own process. • Internet Information Server (IIS) – BasicHttpBinding provides a web service. – wsHttpBinding provides web service with ws* extensions. • Windows Activation Service (WAS) – Uses virtual directory, like web service. 19
  • 20. Service Behaviors • Instancing: – Singleton: one instance for all clients – Per call: one instance per service call – Private session: one instance per client session – Shared session: one instance per session shared between clients • Concurrency models for instances: – Single: one thread at a time accesses instance – Multiple: more than one thread may enter instance – Reentrant: threads make recursive calls without deadlock 20
  • 21. Other Service Behaviors • Throttling: – Limits on number of messages, instances, and threads a service can process simultaneously • Error handling: – Options to handle, let framework handle, and report to client • Metadata: – Services can be self-describing, providing MEX endpoints • Lifetime: – Can specify session duration, service operations to initiate sessions and others to terminate sessions • Security: – Can specify message confidentiality, integrity, authentication, authorization, auditing, and replay detection. 21
  • 22. Structuring Service Code Service Class Attribute Service contract interface [ServiceContract] Service operation method [OperationContract] Implementation class [ServiceBehavior] Derive from contract interface Implementation method [OperationBehavior] Data Contract class [DataContract] class [DataMember] member Message Contract interface [MessageContract] interface [MessageHeader] member [MessageBody] member 22
  • 23. Building Clients • Build proxy with svcutil – Visual Studio will do that if you add a service or web reference – Proxy code is in a subdirectory under the project. • Add proxy code to project • Add “using System.ServiceModel” to client code • Build and run 23
  • 24. Generating Proxies • SvcUtil.exe generates code: – from a mex endpoint: svcutil http://localhost/myService – from WSDL or XSD files: svcutil myService.wsdl • SvcUtil.exe generates WSDL and XSD files from a service library: – svcutil myService.dll 24
  • 25. Channel Model • You can create a channel programmatically – In this case you access the channel directly without the need of a proxy. • All of the configuration normally done with a Web.config or App.config can also be done programmatically. 25
  • 26. Types of WCF Contracts • WCF supports: – Service contracts • Supports RPCs with native data types – Data contracts • Data contracts provide definitions of user defined data structures for transmission through RPCs – Message contracts • Message contracts support message passing • Instead of calling functions send and receive messages 26
  • 27. 27
  • 28. WCF Samples • Microsoft has provided a large set of very interesting samples: – WCF Samples home: http://msdn.microsoft.com/en-us/library/ms751514.aspx – Setup instructions here: http://msdn.microsoft.com/en-us/library/ms751402.aspx – Download here: http://www.microsoft.com/downloads/details.aspx?FamilyID=0043041F-95D6-4EB7- 966A-C21A737E193A&displaylang=en – Note: • Samples use a single virtual directory, created by the setup process • Builds clear the virtual directory and copy built sample files • Initial setup installs developer certificate, required to run SSL • In Vista, must Run Visual Studio as administrator 28
  • 29. White Papers • The following two white papers, by David Chappell plus the Microsoft samples are a great help learning WCF. – www.davidchappell.com/articles/white_papers/Introducing_WCF_in_. Net_Framework_3.5_v1.0.docx – www.davidchappell.com/articles/white_papers/WCF_Diversity_v1.0.d ocx 29