1 / 35

WINDOWS COMMUNICATION FOUNDATION

OTS Solutions is a leading Software Development Company; make use of latest technologies like ASP.NET, WCF, Ajax-enabled WCF and REST WCF Services by its skilled Developers.

guest39726
Télécharger la présentation

WINDOWS COMMUNICATION FOUNDATION

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WINDOWS COMMUNICATION FOUNDATION www.otssolutions.com

  2. Agenda • Introduction to WCF • What is it? Why use it? • Architecture • Fundamentals and the ABCs of WCF • Hosting • Tooling Support • Handling faults

  3. Introduction to WCF

  4. What is WCF? • Stands for Windows Communication Foundation • One of the 4 pillars of .NET 3.0 • Microsoft’s unified programming model (the service model) for building Service-Oriented Applications

  5. Different technology combined to form WCF.

  6. WCF Architecture

  7. SOA • Service • Small program interacted by well defines message exchanges • Agile, Reliable, Stable, Interoperable, Secure • Four Tenets • Boundaries are Explicit • Services are Autonomous • Services share schema and contract, not class • Service compatibility is based upon policy

  8. SOA solutions used

  9. SOA Use for Mobile platforms

  10. Windows Communication Foundation • WCF provides: • an SDK for creating SOA • a runtime for running Services on Windows • Services send and receive messages • All messages are SOAP messages • WCF takes care of all the plumbing

  11. Why use WCF? • Interoperable and Standards based • Supports WS-* protocols • Unified Programming Model • Unifies previous models like .NET Remoting, ASMX web services, COM+ etc • Productive Programming Model • Declarative • Imperative • Configuration based

  12. WCF Value Proposition • Simplicity • Flexibility • Maintainability • Power

  13. WCF: How does it work? • SOAP over HTTP • SOAP over Message Queues • SOAP over TCP SOAP Message Client Service SOAP Message

  14. WCF End points A = Address (Where) B = Binding (How) C = Contract (What) A B C Client Service Message A B C A B C C B A

  15. WCF Endpoints Every service has • Address • Where the service is • Binding • How to talk to the service • Contract • What the service can do

  16. Address • Combination of transport, server name, port & path • Transport is determined by the binding • Examples http://localhost:8001 net.tcp://localhost:8002/MyService net.pipe://localhost/MyPipe net.msmq://localhost/private/MyService net.msmq://localhost/MyService http://server:345/Service

  17. Bindings • Transport • HTTP • TCP • MSMQ • Message formats and encoding • Plain text • Binary • Message Transmission Optimization Mechanism (MTOM) • Communication security • No security • Transport security • Message security • Authenticating and authorizing callers

  18. Out of the box Bindings • NetTcpBinding • NetNamedPipeBinding • NetMsmqBinding • NetPeerTcpBinding • WebHttpBinding • MsmqIntegrationBinding • BasicHttpBinding • WSHttpBinding • WS2007HttpBinding • WSDualHttpBinding • WSFederationHttpBinding • WS2007FederationHttpBinding

  19. Contracts • Service contracts • Defines operations, communications and behaviours. • Data contracts • Defines data entities and parameter types. • Fault contracts • Defines error types • Message contracts • Defines message formats

  20. Service Contracts • [ServiceContract] – Defines a ‘set’ of operations • [OperationContract] – Defines a single method • [ServiceContract] • public interface IService • { • [OperationContract] • string GetData(int value); • } • public class ConcreteService : IService • { • public string GetData(int value) • { ... } • public string OtherMethod() • { ... } • }

  21. Data Contracts • [DataContract]– Specifies type as a data contract • [DataMember] – Members that are part of contract • [DataContract] • public class CustomType • { • [DataMember] • public boolMyFlag { get; set; } • [DataMember] • public string MyString { get; set; } • }

  22. Alternative – DataContract • DataContract: created specifically for WCF to serialize types • Attribute contains Name and Namespace properties • DataMember is needed to specify which properties/fields will form part of the contract • Contains EmitDefaultValue, IsRequired, Name, Order properties

  23. Metadata Exchange • Service can also expose endpoint for Metadata Exchange (MEX) • It provides a mechanism for clients to find out about: • Address of other end points • Bindings that are used • Contracts used – Service, Operation, Data, etc

  24. Hosting • IIS • HTTP only • WAS (Windows Activation Service) • Can use any transport • Vista and Windows Server 2008 only • Self hosting • Can use any transport • Can be hosted within Console, WinForms, etc Applications

  25. Tooling Support

  26. Tooling Support • Visual Studio • Separate projects for WCF • “Add Service reference” menu • WCF Configuration Editor • WCF Service Host • WCF Test Tool • SvcUtil – To generate proxies • SvcTraceViewer – To view logs

  27. Handling Faults

  28. SOAP Faults • Three main kinds of Exceptions can occur: • Communication errors • Unexpected error on the service • Errors thrown by the service on purpose • .NET Exceptions are technology specific • All Exceptions come across the wire as SOAP Faults

  29. Faults • In WCF, SOAP faults are passed in as FaultException objects • Rather than throwing Exceptions, services should throw FaultExceptions • Or better still FaultException<T> • Throwing FaultExceptions will not fault the proxy and the channel

  30. FaultContracts • Specifies what kind of Exceptions, an operation can throw • [ServiceContract] • public interface IEmployeeService • { • [OperationContract] • [FaultContract(typeof(ValidationException))] • public void AddEmployee(Employee e); • }

  31. Advantage • Its made of a lot of different components, so you can create new components for security, transport, authentication. • In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements. • Its faster than ASMX • Its Interoperability, for java, and more. • WCF is interoperable with other services when compared to .NetRemoting, where the client and service have to be .Net • WCF services provide better reliability and security in compared to ASMX web services.

  32. Disadvantage • WCF is Microsoft's implementation of SOA and hence its APIs are solely controlled by MS which makes interoperability a bit difficult. • To deploy WCF apps, need more underlying hardware resources on the platform on which the WCF applications will be running, since there is an additional layer of abstraction to deal with.

  33. Summary • WCF provides a runtime for creating Service Oriented Apps • Provides a productive programming model. Takes care of: • Messaging and Exchange formats • All Plumbing: Transaction, Reliability, Security, etc • Supports Declarative (via attributes), Imperative (via code) and Configuration based (via config files) programming model • ABCs of Endpoints • Address: Where to go? • Binding: How to get there? • Contract: What to do? • Hosting • IIS, WAS, Self-hosting

  34. Thank You http://www.otssolutions.com/

  35. India Gurgaon ( Haryana ) 795, UdyogVihar, Phase-V Gurgaon(Haryana) India Ph: +91 124 4101350 +91 124 4748100 Write to us at: sales@otssolutions.com United kingdom 88 Wood Street 10th Floor London EC2V 7RS Ph: +44 208 099 1660 Write to us at: sales@otssolutions.com USA 4433 Merlin Way , Soquel CA 95073 United States Ph: +1 408 540 0001 Write to us at: sales@otssolutions.com http://www.otssolutions.com/

More Related