Congyu LiSoftware Developer EngineerQuoc BuiSenior Program Manager
Company: MicrosoftSession Code: DEV 320
Agenda
WCF 4.0 Overview
WCF 4.0 – Simplified Configuration
WCF 4.0 – Service Discovery
WCF 4.0 – Routing Service
WCF 4.0 – Improved REST Support
Summary
WCF 4.0
Simplified developer experience
Enables new scenarios/features
Fairly minor in terms of impact to your applications
WCF 4.0:
New WCF 4.0 Features
Simplified configuration
Service Discovery
Router Service
Improved REST support
Simplified Configuration
New support for default service configurationsDefault binding & behavior configurations
Implicit endpoint configurations
Much easier to get services up and runningRemoves the need for <service> configuration
Also enables file-less activation (no .svc)
Example : Configuration for WCF Web Services
EndpointA: http://localhost/service/ICalculator/MEXB: mexHttpBindingC: IMetadataExchange
machine.configC:\Windows\Microsoft.NET\Framework\v4.0.11125\Config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name=""/>
</wsHttpBinding>
</bindings>
<behaviors>
<service>
<behavior name="">
<serviceMetadata
httpGetEnabled="true" />
</behavior>
<service>
<behaviors>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding/>
</wsHttpBinding>
</bindings>
<behaviors>
<service>
<behavior>
<serviceMetadata
httpGetEnabled="true" />
</behavior>
<service>
</behaviors>
Host
(Root) web.configC:\Windows\Microsoft.NET\Framework\v4.0.11125\Config
EndpointA: http://localhost/service/ICalculatorB: WSHttpBindingC: ICalculator
IIS Metabase
Enabled Protocols: HTTPBaseAddress:http://localhost/service
IIS vdir (/localhost/Service)
Service.svcService.dll
Default Behavior
Default Binding
web.config/localhost/development
<system.serviceModel>
<behaviors>
<service>
<behavior>
<serviceDebug/>
</behavior>
<service>
</behaviors>
No web.config
Default Behavior
Example : Configuration for WCF Web Services
WCF 3.5
9
WCF 4.0
Simplified Configuration
Discovery Overview
Motivations…Applications are dynamic and composite in nature
Multiple types of components involved
It is difficult to find existing service assets
WCF Discovery
Framework component
Ships as a DLLProxyServiceClient
Query forServices
Listen forAnnouncements Announce
Respond to Queries
Listen forAnnouncements
Respond toQueries
Service Discovery
WCF 4.0 provides two types of service discovery
Clients can discover services on a local subnet (UDP-based)
Clients can discover services on a larger "managed" network (beyond the local subnet) through a discovery proxy
Ad-Hoc Managed
Enabled via the serviceDiscovery behavior,clients "discover" services using a DynamicEndpoint
Ad-Hoc Discovery
WCF ClientApplication
Billing Service
OrderService
Invoice ProcessingService
Order ServiceLocated
Invoice Processing
Service Located
Managed Discovery
WCF Client Application
Discovery Proxy
InvoiceProcessingService
Billing Service
Invoice Processing Persisted ServiceBilling Service
Billing ServiceLocated
Client Operations
Search for services based on criteriaService Contract
Scopes
Extensions
Dynamic Endpoint of Discovery Client
Host Announcement Service
Service Operations
Enable Service DiscoveryAllows the service to listen for and respond to discovery messages
Announcements
Customizations:Discoverability of individual endpoints
Decorate Endpoints with scopes
Extensions
Discovery Proxy
Facilitates Managed ModeResponds to discovery messages:
Find, Announcements, etc…
“Discovery Head” on your custom repository
Base Classes Provided
Benefits of Service Discovery
Reduced Maintenance Costs
Robust Applications
Scale
Service Discovery based on WS-Discovery
Why build an intermediary?
Service Aggregations
Versioning
Protocol bridging
Application Load-balancing
Service Bus
Challenges
When writing an intermediary you have to think about:
Transactions
Security
Error handling
Multicast v. Unicast
SOAP v. REST
Dynamic Environments
Reliability, Availability, and Performance
WCF Router CapabilitiesContent Based Routing
MessageFilters
MessageFilterTable
SOAP Headers
Xpath
Protocol Binding
System Provided Bindings
Error Handling
CommunicationException & TimeOut
Error Path Definition
“On failure, resend to:”
Dynamic Reconfiguration
On Event, rebuild rules/destination set
Don’t disrupt in-flight messages/sessions
Example : Error Handling & Protocol Bridging
CalcClient
Backup
RoutingService
WS-HttpNet.Tcp
ICalcService
Example:Complex Filters
Calc
Client
RoundICalc
Routing
Service
RegularICalc
Filter Rules Priority
If (has header) Round ICalc 2
If (showed up on Ep2) Regular ICalc 1
If (showed up w/ Address 2) Round ICalc 1
If (RoundRobin1) Regular ICalc 0
If (RoundRobin2) Round ICalc 0
Example : Dynamic Reconfiguration
Calc
Client
Round
ICalc
Routing
Service
Regular
ICalc
Example:Advanced Error Handling
Service Queues
RoutingServiceInQ
Pri
mar
y
bac
kup
Logging Queues
Pri
mar
y
bac
kup
DLQ
Routing Service
New Features
Simplified Development:•Simplified Config•ASP.NET Routes
Simplified Programming:•No [OperationContract]•WebFaultException
Simplified Consumption:•Help Page
Formatting:•Automatic XML/JSON•Content Nego API•Multiple Formats
Caching:•ASP.NET Output Cache•Conditional GET & PUT
AJAX:•JSONP
Simplified Development
Simplified ConfigurationDefault standard Endpoint
Customizable standardEndpoint
ASP.Net RoutesUsage Example Simplified Development:
•Simplified Config•ASP.NET Routes
Formatting
Automatic XML/JSONBased on request header : Accepts/Content-Type
Scenario of specifying XML/JSONFormatting:
•Automatic XML/JSON•Content Nego API•Multiple Formats
Example:Automatic XML/JSON
35
Caching Support
ASP.NET caching
Conditional GET/PUT
Caching:•ASP.NET Output Cache•Conditional GET & PUT
Simplified Consumption
Automatically generating help pageGenerate XHTML help page for each service, including URL and message example
Simplified Consumption:•Help Page
AJAX
JSONPDefault callback property
Customized callback property
AJAX:•JSONP
Improved REST Support
Summary
New in 4.0Simplified developer experience
Enables new scenarios/features
Resources
Learning and Downloads:WF 3.x: http://msdn.microsoft.com/workflowWF 4: http://msdn.microsoft.com/workflow/future/WCF 3.x: http://msdn.microsoft.com/wcfWCF 4: http://msdn.microsoft.com/wcf/future
To ask questions:http://social.msdn.microsoft.com/forums/en-US/wcfhttp://social.msdn.microsoft.com/Forums/en-US/wcfprereleasehttp://social.msdn.microsoft.com/forums/en-US/windowsworkflowfoundationhttp://social.msdn.microsoft.com/Forums/en-US/wfprerelease
To provide Suggestions:https://connect.microsoft.com/wfhttps://connect.microsoft.com/wcf
Resources for .Net(Documents, Samples, Demos etc.)http://dotnet
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Client DMZDe-Militarized Zone
DMZ (inner) Internal
Internet Browser
Web Service
(IIS)
Reverse Proxy(ISA)
Load Balancer
Application Server
(WCF, BTS, WF)
Application Server
(WCF, BTS, WF)
Application Server
(WCF, BTS, WF)
192.168.0.1
59.188.192.36 65.55.17.25Externally exposed IP address
200.200.200.1translator
200.200.200.2Internal IP address
20
0.2
00
.20
0.1
02
00
.20
0.2
00
.11
20
0.2
00
.20
0.1
2