1 / 34

Getting Started with Windows Communication Foundation 4.5

Getting Started with Windows Communication Foundation 4.5. Ed Jones, MCT, MCPD, MCTS Consultant RBA Inc. Welcome to TechFuse!. Objective: To give you enough information to get started at building a WCF solution! To get the most out of this session, you need to know…

Sophia
Download Presentation

Getting Started with Windows Communication Foundation 4.5

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. Getting Started with Windows Communication Foundation 4.5 Ed Jones, MCT, MCPD, MCTSConsultantRBA Inc.

  2. Welcome to TechFuse! • Objective: To give you enough information to get started at building a WCF solution! • To get the most out of this session, you need to know… • .NET Programming (all samples in C#) • Simple configuration (.config files)

  3. Overview • TechFuse Suites: our sample application • What does it mean to be SOA? • Contracts and Service Implementation • Bindings and Behaviors • Hosting the Service • Consuming WCF Services • What’s New in WCF 4.5?

  4. TechFuse Suites • A simple service that allows one to make, alter, or cancel a reservation at TechFuse Suites. • The reservation system is available to any client regardless of type of code, native OS, etc. • Architecture • The reservation system is a WCF 4.5 Service • The service is hosted in a Windows Service over http and netTcp • The database is SQL Server 2012 • Supports multiple clients: • Windows Forms • Java-Based (we’ll use the SOAP UI tool) • Sample Code and Database available at: http://sdrv.ms/13ZU79u

  5. Service Oriented Architecture and Principles

  6. What is service orientation? • Service-Oriented Architecture (SOA) is a set of principles and methodologies for designing and developing software in the form of interoperable services. These services are well-defined business functionalities that are built as software components (discrete pieces of code and/or data structures) that can be reused for different purposes. SOA design principles are used during the phases of systems development and integration. -Wikipedia, “Service-Oriented Architecture”

  7. Or better yet… • A loosely-coupled architecture designed to meet the business needs of the organization.

  8. SOA Design Principles • Boundaries Are Explicit • Services Are Autonomous • Services Share Schema & Contract, Not Class • Service Compatibility Is Based Upon Policy

  9. What is WCF? • Windows Communication Foundation (WCF) is a framework for building service-oriented applications. • It is a runtime and a set of APIs for creating systems that send messages between services and clients. • WCF is the foundation for other distributed technologies by Microsoft, such as Azure, AppFabric, and BizTalk

  10. How it works: A WCF Overview

  11. WCF Contracts Building out service and data contracts

  12. WCF Contracts • Contracts determine what data and operations are exposed • Service contracts define operations • Data contracts define data (duh!) • And you’ve got other contracts, too • Message Contracts • Fault Contracts

  13. A Contract Is Just a Schema…

  14. Service Contracts

  15. Data Contracts

  16. TechFuse Suites: Contracts and Implementation

  17. Configuring the Service

  18. Bindings • The binding controls the messaging details (what happens on the wire) for that endpoint. • Common bindings are common recipes as to how WCF will configure the underlying channel stacks. • There are countless extensibility points found throughout the WCF channel layer

  19. Sample Binding (older WCF)

  20. ABC’s: Address, Binding, Contract

  21. TechFuse Suites: Configuration

  22. Hosting the Service

  23. Hosting the Service • A WCF Service is a library, it has no life of its own • The host brings the WCF service to life by providing the process in which it operates. • Most of the time, WCF services will run in a ready-made host environment such as Internet Information Server (IIS) or Azure • A lot of things require a host!

  24. Creating the Host • Create references to: • System.Runtime.Serialization • System.ServiceModel • Your WCF service assembly • Create an instance of the ServiceHost class (System.ServiceModel.ServiceHost), passing in a reference to your own service class • Call ServiceHost.Open() to start your service and ServiceHost.Close() to stop it. • Configure the server settings in the .config file for the Host application.

  25. TechFuse Suites: Host Application

  26. Using a WCF Service Creating a Client

  27. Consuming a service • Because WCF exposes service functionality through open standards, such as SOAP, you can use almost any type of client to consume the service. • Allowing a .NET client to consume the service is as easy as creating a service reference or generating a proxy through a command-line utility (svcutil.exe) • Non-.NET clients would typically use SOAP to consume a WCF Service

  28. Creating the Client • Create a proxy class by using svcutil.exe or creating a service reference. • Configure the client settings in the .config file for the client application • Call the open method on the proxy to establish a connection to the service and the close method to end it. • Call the operations on the service as you would any method

  29. A TechFuse Suites Client

  30. Other Things You Can Do with WCF • Secure Services • RESTful Services • Routing • Streaming • Discovery • Web Sockets • …and much, much, more

  31. What’s New in WCF 4.5 • Config File Tootips, IntelliSense • Contract-First Generation • Generate Classes from Sample XML • ASP.NET compatibility mode defaults to “true” • WCF Configuration Validation • Streaming Improvements • Single WSDL • ChannelFactory Caching • UDP Support • HttpClient Class

  32. Review • What does it mean to be SOA? • Contracts and Service Implementation • Bindings and Behaviors • Hosting the Service • Consuming WCF Services • What’s New in WCF 4.5?

  33. References • Wikipedia – “Service-Oriented Architecture” http://en.wikipedia.org/wiki/Service-oriented_architecture • Stefan Tilkov, “10 Principles of SOA” http://www.infoq.com/articles/tilkov-10-soa-principles • John Spacey, “The 9 Principles of Service Oriented Design” http://simplicable.com/new/the-9-principles-of-soa-design • MSDN, “How to: Host a WCF Service in a Managed Windows Service” http://msdn.microsoft.com/en-us/library/ms733069.aspx • MSDN, “What’s New in Windows Communication Foundation 4.5” http://msdn.microsoft.com/en-us/library/dd456789.aspx • MSDN, “Basic WCF Programming” http://msdn.microsoft.com/en-us/library/ms731067.aspx • MSDN, “Chapter 1: Service Oriented Architecture” http://msdn.microsoft.com/en-us/library/bb833022.aspx

  34. Thank You! • Ed Jones,MCT, MCPD (Web, Azure), MCTS (WCF, BizTalk) • Email: ed.jones@rbaconsulting.com • Blog: http://talentedmonkeys.wordpress.com • LinkedIn: http://www.linkedin.com/in/edjjones/ http://www.rbaconsulting.com

More Related