Windows Communication Foundation (WCF) is one of the leading technologies for building distributed applications. WCF 4.5 which ships with the new .NET 4.5 and Visual Studio 2012 introduces many new features that both simplifies the way we create services and enables us improve the way our services work. In this session we will see many of the new features offered by WCF 4.5 – configuration Intellisense, cleaner configuration for IIS, UDP and WebSockets supports, and many more.
2. About Me
• Senior architect, Sela Group
• Co-author of:
– Developing Windows Azure and Web
Services – Microsoft official course
– WCF 4 – Microsoft official course
– Pro .NET Performance – Apress
• Microsoft MVP
• Focus on server, services, and cloud
technologies
• Manager of the Israeli Web
Developers User Group
3. What is WCF?
• WCF is a unified .NET framework for building
service-oriented applications
• WCF was introduced in .NET Framework 3.0 and
extended in .NET 3.5, .NET 4, and .NET 4.5
• WCF is the foundation for other Microsoft
distributed technologies
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
4. Do You Like WCF?
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
5. Common WCF Configuration Issues
•
•
•
•
Using wrong service / contract names
Need to remember binding names
Copy & pasting configuration names
Configuration duplication for WCF and IIS
Image: chanpipat / FreeDigitalPhotos.net
• Some configuration issues were addressed in
WCF 4
• Visual Studio 2012 & WCF 4.5 continue the
simplification process
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
6. Visual Studio 2012
Editor Simplification
• IntelliSense
– Service name
– Contract name
– Binding type
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
7. Visual Studio 2012
Editor Simplification
• IntelliSense
–
–
–
–
–
Service name
Contract name
Binding type
Binding configuration
Behavior configuration
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
8. Visual Studio 2012
Editor Simplification
• IntelliSense
–
–
–
–
–
Service name
Contract name
Binding type
Binding configuration
Behavior
configuration
• Tooltips
• Compile-time
validations
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
9. Cleaner Endpoint Configuration for IIS
• Multiple IIS authentication types in one binding
– Bindings can inherit authentication types from IIS
– Instead of multiple endpoints, declare just one!
– Set the binding’s clientCredentialType to InheritedFromHost
• New default endpoint for HTTPS
– No need to declare endpoints if using both HTTP and HTTPS
– Default HTTPS endpoints don’t require client credentials
– Customize default endpoints in the ProtocolMapping section
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
10. What Other Mess Got Cleaned Up?
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
13. Duplex Communication with HTTP
• HTTP is a request-response protocol
• Updates are through server polling
– Periodic polling (Anything new?)
– Long polling (I’m waiting for you!)
• Many disadvantages
– Periodic polling inflicts high-latency on updates
– Long polling is hard to implement
– Can cause bandwidth overhead if used
improperly
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
14. WebSockets in a Glance
•
•
•
•
•
•
•
Bi-directional TCP channel (full-duplex)
Supports both HTTP and HTTPS (SSL)
Accessible through JavaScript API
Supports cross-domain calls
Client-side - IE10, Chrome, Firefox, WCF 4.5
Server-side – IIS 8, ASP.NET 4.5, WCF 4.5
Standardization is still in progress!!
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
15. WebSockets and WCF 4.5
• WCF 4.5 supports WebSockets in two modes:
– SOAP over WebSockets (.NET)
– Plain text over WebSockets (browsers)
• For SOAP use NetHttpBinding
• For browsers, use the Microsoft.WebSockets
NuGet package
– Create a service class by inheriting from
WebSocketService
– Implement control methods – OnOpen, OnStop,
OnMessage, OnError
– Send messages to client by calling the Send method
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
17. WCF and UDP – Q&A
• WCF 3.5
– “Does WCF support UDP bindings?”
– “Not out-of-the-box, but there is an MS sample for that”
• WCF 4
–
–
–
–
“Does WCF support UDP?”
“Not out-of-the-box, but there is an MS sample for that”
“But Discovery uses UDP, right?”
“Indeed, but the UDP transport channel is internally used”
• WCF 4.5
– “Does WCF support UDP?”
– “YES!!”
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
18. UDP Transport
•
•
•
•
New UDP binding out-of-the-box
Supports one-way and request-response
Unicast – you do not get an exception if host is down!!
Multicast messaging is supported through IPs such as
224.0.0.1 – 239.255.255.255
• Supported features are basic
–
–
–
–
Only text encoding
No sessions
No security
No duplex
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
20. Improved Channels and Encoding
• Web hosting (IIS)
– Fixed streamed messages from being buffered in ASP.NET
– Added async streamed reply for slow reading clients
• Self hosting
– Support for binary encoding compression (Gzip / Deflate)
– Works with TCP and custom HTTP transports
• Both hosting environment
– New transport defaults for TCP and named pipe transports
– Defaults are now multiplied by #cores to enable
high-density scenarios
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
22. To Conclude
• Yet another effort to simplify the creation of
WCF services and clients
• Continuing to support new and existing
standards
• Striving to improve the overall performance of
WCF
Join the conversation on Twitter: @SoftArchConf #SoftArchConf
23. WCF Resources
WCF Home and Forum
msdn.microsoft.com/en-us/library/dd456779.aspx
social.msdn.microsoft.com/forums/en/wcf
WCF Blogs
blogs.msdn.com/b/piyushjo
blogs.msdn.com/b/carlosfigueira
WCF vNext UserVoice
tinyurl.com/wcfvnext
My Info
blogs.microsoft.co.il/blogs/idof
idof@sela.co.il
@idoFlatow
This presentation: sdrv.ms/1b94Zmb