What's new in Wcf4

521 views

Published on

This presentation is prepared for the MUGH session.

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
521
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

What's new in Wcf4

  1. 1. What’s new in WCF 4.0 about.me/Chakravarthy
  2. 2. About ME • MCA, MVP, MCPD, MCTS and CSM • j.mp/CareerHistory • Developer turned Architect – WHAT !! – Who else !! • Community Person
  3. 3. Agenda • What’s new !!?? – Configuration – Tracing – Serialization – Message queuing – Service discovery – Routing – Workflow services
  4. 4. Let’s start ..
  5. 5. What’s new in WCF
  6. 6. Kalpana (1948) is a Bollywood movie from a time before the term had been invented. This 155-minute-long black-and-white feature film gives full rein to the talents of choreographer Uday Shankar, the film’s director and a legend of Indian dance. The film is about a young dancer who dreams of founding his own dance school, played by the director himself. Despite living until the age of 76, Kalpana is the one and only film Uday Shankar directed in his entire career. In the dance world, however, he will be remembered as a veritable master of the art of choreography. Kalpana will be screened at Cannes Classics on Thursday 17th May at 19:30, Salle Buñuel.
  7. 7. Far from the world of Indian dancing, After the Curfew (1954) has as its backdrop the post-war period in Indonesia. In the months following independence, Iskandar returns to civilian life. For this medical student it is a time of bitter disillusionment, as he sees corruption and political incompetence take hold throughout the country. The director, Usmar Ismail, is considered as one of the forefathers of Indonesian cinema. He made a major contribution to the development of Indonesian cinema in the 1950s by founding Perfini, the country’s first film studios. After The Curfew will be screened at Cannes Classics on Thursday 17th May at 17:15, Salle Buñuel.
  8. 8. ??!!
  9. 9. a) Configuration Improvements • Removed the need for explicit per-service configuration • default values for WCF bindings & behaviors • the standard endpoint, which will allow you to define reusable preconfigured endpoints Source : http://j.mp/WCF4ConfigImp
  10. 10. Default bindings & behaviors You can also define default binding and behavior configurations • Simply define the binding/behavior without a name • That binding takes effect for anything not assigned a specific binding • Can be defined at different scopes within config (e.g. machine.config) <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors>
  11. 11. Configuration Improvements Source : http://j.mp/WCF4ConfigImp
  12. 12. File-less activation • In WCF 4, you no longer need physical .svc files to activate services – Instead you can define a virtual mapping in config <serviceHostingEnvironment> <serviceActivations> <add relativeAddress ="EntertainmentServices.svc" service="EntertainmentShows"/> </serviceActivations> </serviceHostingEnvironment> </system.serviceModel>
  13. 13. Default endpoints • WCF 3.x services required at least one endpoint or you’d get an exception • WCF 4.0 services come with default endpoints – One default endpoint per contract/base address combination – Assuming you haven’t defined any manually – If you’ve defined at least one endpoint, you won’t get default endpoints
  14. 14. Standard endpoints • WCF 4 also comes with several “preconfigured” standard endpoints – These cover some of the most common usage scenarios – You can simply reuse them as-is without change • You refer to standard endpoints by name using the “kind” attribute – Makes it easier to get up and running in certain scenarios <endpoint kind ="mexEndpoint" address="mex" />
  15. 15. Formats and Flexibility
  16. 16. multipart/form-data text/calendar application/atom+xml image/svg+xml application/json Approx 900 text/directory App media types! application/xml text/html image/png application/xaml+xml application/x-www-form-urlencoded
  17. 17. preconfigured Standard endpoints in v4.0 Standard endpoint name mexEndpoint dynamicEndpoint discoveryEndpoint udpDiscoveryEndpoint announcementEndpoint udpAnnouncementEndpoint workflowControlEndpoint webHttpEndpoint webScriptEndpoint Description Defines a standard endpoint for MEX configured with IMetadataExchange for the service contract, mexHttpBinding as the default binding (you can change this), and an empty address. Defines a standard endpoint configured to use WCF Discovery within a WCF client application. When using this standard endpoint, an address is not required because during the first call, the client will query for a service endpoint matching the specified contract and automatically connect to it for you. Defines a standard endpoint that is pre-configured for discovery operations within a client application. The user needs to specify the address and the binding when using this standard endpoint. Defines a standard endpoint that is pre-configured for discovery operations within a client application using the UDP binding at a multicast address. Derives from DiscoveryEndpoint. Defines a standard endpoint that is pre-configured for the announcement functionality of discovery. The user needs to specify the address and the binding when using this standard endpoint. Defines a standard endpoint that is pre-configured for the announcement functionality over a UDP binding at a multicast address. This endpoint derives from announcementEndpoint. Defines a standard endpoint for controlling execution of workflow instances (create, run, suspend, terminate, etc). Defines a standard endpoint configured with WebHttpBinding and WebHttpBehavior. Use to expose REST services. Defines a standard endpoint configured with WebHttpBinding and WebScriptEnablingBehavior. Use to expose Ajax services.
  18. 18. Default protocol mapping <protocolMapping> <add scheme="http" binding="basicHttpBinding" bindingConfiguration="" /> <add scheme="net.tcp" binding="netTcpBinding" bindingConfiguration=""/> <add scheme="net.pipe" binding="netNamedPipeBinding" bindingConfiguration="" <add scheme="net.msmq" binding="netMsmqBinding" bindingConfiguration=""/> </protocolMapping>
  19. 19. How to choose a Binding Yes Yes Local Only No Inside Firewall & .NET to .NET No Yes No MSMQ Client Support Legacy? Need to Disconnect Yes NetTcp Binding Yes No No NetMsmq Binding NetNamedPipe Binding Msmq Integration Binding WsHttp Binding BasicHttp Binding
  20. 20. Default behavior configuration <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <!-- notice no name attribute --> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
  21. 21. Routing Service
  22. 22. Message Pump as a Service Routing Message Service Pump Scenarios Concerns • • • • • • • • • • Basic Message Routing Protocol Bridging Service Aggregation Versioning … Connection State Security Delivery Failure Transactions …
  23. 23. Message Routing Echo Routing Service Client A B C Time Service Supported Message Exchange Patterns Multicast Interface Request Reply, Sessionful Request Reply No IRequestReplyRouter OneWay Yes ISimplexDatagramRouter Sessionful OneWay Yes ISimplexSessionRouter Sessionful Duplex Yes IDuplexSessionRouter
  24. 24. Message Routing Echo Routing Service Client MessageFilter Endpoint action == http://Message/Echo Echo action == http://Message/GetCurrentTime TimeService Filter On MessageFilter Action ActionMessageFilter Address header AddressMessageFilter Address header – longest prefix matching AddressPrefixMessageFilter Endpoint Name EndpointNameMessageFilter No Filter – matches everything MatchAllMessageFilter Logical And of two filters StrictAndMessageFilter XPath expression XPathMessageFilter Custom Custom Time Service
  25. 25. Protocol Bridging Routing Service Client BasicHttp SOAP 1.1 Service Net.Tcp SOAP 1.2
  26. 26. Security Client Routing Service Service
  27. 27. Error Handling Echo Service Routing Service Client Backup Echo Service MessageFilter Endpoint action == http://Message/Echo Echo Alternate Endpoints Backup EchoService
  28. 28. Router Service • First-class "router" service – Simply host the RoutingService class – You host it like any other WCF service – Configure with routing “filters” to do content-based routing
  29. 29. Hosting the RoutingService • Additional routing service capabilities – Protocol bridging (client sends over HTTP, router sends over TCP, etc) – Error handling support (router configured with backup endpoints) – Multi-cast routing support (router sends to multiple endpoints)
  30. 30. Using the Routing Service 1. 2. Create regular WCF Services to be called by the Routing Service. Create a Routing Service: a. Change the markup in the .svc file to point to the routing Service. Be sure to reference System.ServiceModel.Routing in your project b. In the web.config: 1) Add endpoints for all the services to which you’ll connect in the <client> section. <client> <endpoint name="CalculatorService1" address="net.tcp://localhost:8001/servicemodelsamples/calcservice1" binding="netTcpBinding" contract="*" /> <endpoint name="CalculatorService2" address="net.pipe://localhost/servicemodelsamples/calcservice2" binding="netNamedPipeBinding" contract="*" /> </client>
  31. 31. Using the Routing Service (cont’d) b. In the web.config (cont’d): 2) Create a namespace filter and set the Xpath filterData 3) Add filterTables to point to the correct end points 4) Set the Routing behavior to identify the filterTables
  32. 32. WCF WebHttp Services
  33. 33. Improved REST Support • Many features in the WCF REST Starter Kit are now part of WCF 4.0 Automatic help page HTTP caching WCF/ASP.NE T routes Message format selection REST project templates HTTP “faults” Various API extensions
  34. 34. Automatic help page • WCF 4 provides an automatic help page for REST services – Configure the <webHttp> behavior with helpEnabled=“true”
  35. 35. Message format selection • WCF 4 also provides automatic format selection for XML/JSON – This feature is built on the HTTP “Accept” headers <configuration> <system.serviceModel> <standardEndpoints> <webHttpEndpoint> <!-- the "" standard endpoint is used for auto creating a web endpoint. --> <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/> </webHttpEndpoint> </standardEndpoints> </system.serviceModel> </configuration>
  36. 36. WCF and ASP.NET routes • WCF 4 provides the ability to integrate with the ASP.NET routing engine – You implement RegisterRoutes in Global.asax, add ServiceRoute mappings – ServiceRoute allows you to map a URL to a WCF 4 service class • Ultimately this gives you a URL space that maps to multiple WCF classes private void RegisterRoutes() { WebServiceHostFactory factory = new WebServiceHostFactory(); RouteTable.Routes.Add(new ServiceRoute("Bookmarks", factory, typeof(BookmarkService))); RouteTable.Routes.Add(new ServiceRoute("Users", factory, typeof(UserService))); }
  37. 37. REST project templates • Download the new REST project templates via the new Visual Studio 2010 Extension Manager (Tools | Extension Manager)
  38. 38. • Summary WCF/WF 4.0 offers many improvements: – – – – – Simplified configuration Discovery Routing service WebHttp services Workflow services • These improvements make WCF simpler and more flexible – Today’s common use cases just got easier
  39. 39. Thanks

×