300 likes | 511 Views
Windows Communication Framework (WCF) Code-Named “Indigo”. “Microsoft’s next-generation Web Services technology, Indigo, will significantly expand both the scope and the capabilities of Web Services” -Gartner, Feb 11 th 2005. Agenda. What is WCF (Indigo)?
E N D
Windows Communication Framework (WCF) Code-Named “Indigo” “Microsoft’s next-generation Web Services technology, Indigo, will significantly expand both the scope and the capabilities of Web Services” -Gartner, Feb 11th 2005
Agenda • What is WCF (Indigo)? • Existing Microsoft Distributed Application Technologies • Shipping Schedule and Platforms • Relation to BizTalk and Visual Studio 2005 (Whidbey) • Object vs Service-Oriented Development • WCF Programming Model • Service Class • Service and Data Contracts • Hosting a WCF Service • Endpoints • Bindings • WCF Client Proxy • Interoperability and Migration to WCF (Indigo) • Appendicies • Other WCF Offerings • WCF Relation to SOA and Enterprise Service Bus (ESB) • WCF Architecture • WCF Supported WS-* Standards • Resources – Video & Article
What is WCF (Indigo)? Windows Communication Framework, code-named Indigo, is Microsoft’s new unified programming model for developing distributed application based on service-orientation. We say “unified” because WCF encompasses and further extends the capabilities of Microsoft’s existing technolgies for building distributed applications. • ASMX (web services) • .NET Remoting • Web Services Enhancements (WSE) • .NET Enterprise Services (successor to COM+) • System.Messaging (successor to MSMQ)
WCF – Unified Programming Model • WCF is built on top of and extends the Microsoft .NET Framework v2.0 in the System.ServiceModel namespace. • WCF consolidates all current distributed application development technologies under a single API and framework. • Developers continue to develop distributed applications in the object-oriented manner they used to and Indigo takes care of the service-oriented plumbing (more on this later).
Existing Microsoft Distributed Application Technologies • ASMX • Originally shipped with the .NET Framework v1.0 and referred to as XML Web Services. • Used to create basic web services functionality within ASP.NET. • Supports only SOAP 1.1 over HTTP and WSDL 1.1. • Performance greatly improved in the .NET Framework v1.1, but lacked WS-* support • Upcoming ASMX v2.0 will bring support for SOAP v1.2 but no support for WS-* Standards • .NET Remoting • Shipped as part of the .NET Framework v1.0 • Ideally used for information exchange between .NET applications. • Web Services Enhancements (WSE) • Currently WSE 1.0 and WSE 2.0 as released. WSE 3.0 will be released along with VS2005 • Used to support advanced WS-* web services standards such as WS-Security, WS-Trust, WS-Addressing. • Used in conjunction with ASMX to provide WS-* support, or independently to build web services. • .NET Enterprise Services (successor to COM+) • The .NET implementation of COM+ • Used to implement distributed transactions in a Microsoft Enterprise • System.Messaging (successor to MSMQ) • The .NET implementation of MSMQ • Used for queue management functionality
WCF – Future of MS Programming “Microsoft’s overwhelming dominance in desktop operating systems means that Indigo will automatically have an enormous impact, jump-stating a new generation of web services-enabled application and expanding the possibilities of services-oriented architectures.” - Gartner, Feb 11 2005 “Indigo is a ‘platformization’…By turning it (Indigo) into an operating system component, we’re able to get a level of performance and compatibility out of this, which is uncharacteristic. - John Shewchuk, Microsoft Indigo Architect “Indigo makes it easier for an average Microsoft solutions provider to build enterprise distributed software” - Tim Huckaby, CEO of InterKnowlogy “deliver a unified development experience across multiple axes, including distance (cross-process, cross-machine, cross-subnet, cross-intranet, cross-Internet), topologies (farms, fire-walled, content-routed, dynamic), hosts (ASP.NET, EXE, Windows Presentation Foundation, Windows Forms, NT Service, COM+), protocols (TCP, HTTP, cross-process, custom), and security models (SAML, Kerberos, X509, username/password, custom).” MSDN – Windows Communication Framework FAQ
Shipping Schedule and Platforms • The Community Technology Preview (CTP) of WCF was released in March 2005. A Beta was released in May 2005. Final release in 2006. More details in Shipping Schedule and Vehicles section. • Final version of WCF will be shipped as part of Microsoft’s next operating system, Windows Vista (code-named ‘Longhorn’), sometime in 2006. • WCF will also be available for both Windows XP and Windows Server 2003 as part of the WinFX Runtime Components. WinFX is the new windows programming interface for Windows Vista. • Since WCF extends it with the System.ServiceModel • namespace, it’s delivery mechanism will be similar to • the that of the .NET Framework
Relation to BizTalk Server Technology • WCF and BizTalk are complementary technologies. • BizTalk offers business process orchestration, message transformation and business activity monitoring via GUI tools • WCF is a unified programming framework for developing service-oriented distributed applications. When the final version of WCF ships, BizTalk will offer an adapter that will allow WCF services to participate in business process orchestration. In future versions of BizTalk, WCF will become the core for BizTalk’s messaging and web services functionality.
Relation to Visual Studio 2005 (Whidbey) Visual Studio 2005 (code-named Whidbey) is the next .NET IDE release and will be based on the new Microsoft .NET Framework 2.0 Since WCF extends the .NET Framework 2.0 as a set of additional managed class libraries under the System.ServiceModel namespace, it is fully compatible with VS2005. Developers can thus program distributed service-oriented applications with WCF in VS2005 in the CLR-compatible language of their choice.
Object and Service Oriented Development • Do object-oriented and service-oriented development conflict? • They are complementary. Serve two separate purposes: • OO - Used in the internal design of applications for functional and business logic • SO – Better suited for application-to-application communication than objects. • There are plenty of OO mature development tools available, but using services as a fundamental software building block is a new idea. There are few semi-mature IDEs. • Both Rely on Contracts in some way. [Explain] • Enter WCF (Indigo) • WCF allows developers who are used to designing object-oriented applications based on the .NET Framework to also build service-oriented applications in a very similar way. • Since WCF utilizes the SOAP transport, developer applications can interact with Windows and non-Windows applications utilizing reliability, security, and transactions. • Four Tenets for Service-Orientation in WCF • Share Schema, not Class – Clients\Services only interact standardized XML contracts. • Services are Autonomous – Clients\Services agree only on contracts, not implementation. • Boundaries are Explicit – i.e. DCOM tried to disguise remote objects as local objects • Use Policy-Based Compatibility – Standards such as WS-Policy are used to determine which optional requirements (security, addressing) a client and service must implement.
WCF Programming Model • Core Concepts • Service Class • Service Contract • Data Contract • Host Environment • Endpoints • Bindings
WCF Service Class A WFC service class is the same as an OO class, but they additionally define one or more contracts which it implements. Each WFC service class implements at least one service class, which defines the methods and operations of a web service. Optionally, a WFC service class may implement a data contract, which defines the structure of complex data the service may exchange.
WCF Service Contract • Essentially the service contract defines which methods in the service class are exposed and callable by a web services client. • How is this achieved in the .NET World? • The designers of the Common Language Runtime (CLR) anticipated the need for extensibility in the .NET Framework so they provided support for attributes. Attributes can appear before classandmethod definitions, and a few other places. The presence of attributes changes the behavior of whatever it’s attached to. Some examples are the [WebMethods] attribute in ASMX, or the [Transaction] attribute in Enterprise Services. • Important to distinguish that OO and SO both rely on some kind of contract for exposing methods and properties: • OO uses keywords such as public and private to determine outside (the object) access to methods and properties • SO in WCF uses attributes such as [OperationContract] • Two Ways to Implement a Service Contract • Mark a service class with the [ServiceContract] attribute. • Create a service contract interface, then have separate class implement that interface.
Service Contract Implementation Method #1 Method #2 using System.ServiceModel; [ServiceContract] class Calculator { [OperationContract] private int Add(int a, int b) { return a + b; } [OperationContract] public int Subtract(int a, int b) { return a - b; } public int Multiply(int a, int b) { return a * b; } } using System.ServiceModel; [ServiceContract] interface Icalculator { [OperationContract] int Add(int a, int b); [OperationContract] int Subtract(int a, int b); } class Calculator : ICalculator { public int Add(int a, int b) { return a + b; } public int Subtract(int a, int b) { return a - b; } public int Multiply(int a, int b) { return a * b; } } Interface Service Class
Data Contract Implementation Data Contracts are Optional, and are not required to build a WCF service class. A contract used by the service class to describe the data to be exchanged in a web services communication. More specifically, they define how an in-memory type will be represents on the wire during communication. This transformation process is known as serialization. The reason they are optional is because sometimes the data to be exchange is implicit in the service contract defined. For example, the Add and Subtract methods on the previous slide define that the two inputs are of type Integer and the so is the return value. Method inputs of complex types (i.e. structures) would require an explicit data contract. Data Contracts are defined using the [DataContract] attribute. The attribute is used on classes, structures, and other types. The members (methods and properties) of those types marked with the [DataMember] attribute will be serialized. [Further Explain] [DataContract] struct Customer { [DataMember] public string Name; int public age; [DataMember] private int CreditRating; } In this example, if a method like Add or Subtract took an input of type Customer then only Name and CreditRating would be serialized and passed to the method.
Quick Refresh Point • Core Concepts • Service Class • Service Contract • Data Contract • Host Environment • Endpoints • Bindings
WCF Host Environment (Brief) • A couple of options for hosting WCF Applications exist: • Web Application Hosting • IIS 5.1, 6.0, and 7.0 • SOAP over HTTP only • Self-Hosted Applications • Run in arbitrary process created as a console app or Windows service • Windows Activation Service • Longhorn only feature. Provides IIS functionality without the web server • Can host HTTP, TCP, IPC, and MSMQ solutions. • IIS 7.0 will be based on Windows Activation Service
WCF Endpoints and Bindings • Endpoints • Represent the ‘gateway’ for accessing a WCF service. It’s a point of contact that clients use to interact with the service. A WCF service can have one or more endpoints. • The A, B, C of Endpoints • Endpoints are comprised of three essential elements: • Address – Where is the service located? • Binding – How do I communicate with the service? • Contract – What does the service offer? • All three are independent. A contract can support several bindings and visa versa.
WCF Endpoints - Other Notes Contract A class marked with [ServiceContract] that implements no interfaces, can expose only one service contract. Thus all it’s endpoints expose the same contract. If a class implements two or more interfaces marked with [ServiceContract], then different endpoints can expose different contracts. Address Addresses are URLs that identify a machine and a particular endpoint hosted by that machine. Binding The binding determines what protocol combination can be used to access an endpoint along with other requirements such as whether the communication is reliable and what security mechanisms can be used. For example, if a service allows clients to access it using either SOAP over HTTP or SOAP over TCP then each of these scenarios is a distinct binding. The service would thus need to expose two endpoints, one with a SOAP-over-HTTP binding and the other with a SOAP-over-TCP binding.
WCF Endpoints • An WCF endpoint can be correlated with a WSDL contract. • Address – equivalent to the <wsdl:service> section. • Binding – equivalent to the <wsdl:binding> section. • Contract – equivalent to the <wsdl:portType>, <wsdl:message>, and wsdl:type> sections.
WCF Bindings • WCF comes with several predefined bindings to choose from: • BasicProfileHttpBinding: conforms to the Web services Interoperability Organization (WS-I) Basic Profile 1.0, which specifies SOAP over HTTP. This is an endpoint's default binding if none is explicitly specified. • BasicProfileHttpsBinding: conforms to the WS-I Basic Security Profile 1.0, which specifies SOAP over HTTPS. • WsHttpBinding: supports reliable message transfer with WS-ReliableMessaging, security with WS-Security, and transactions with WS-AtomicTransaction. • WsDualHttpBinding: like WsHttpBinding, but also supports interaction using duplex contracts. Using this binding, both services and clients can receive and send messages. • NetTcpBinding: sends binary-encoded SOAP, including support for reliable message transfer, security, and transactions, directly over TCP. Can only be used for Indigo-to-Indigo communication. • NetNamedPipeBinding: sends binary-encoded SOAP over named pipes. This binding is only usable for Indigo-to-Indigo communication between processes on the same Windows machine. • NetMsmqBinding: sends binary-encoded SOAP over MSMQ, as described later. This binding can only be used for Indigo-to-Indigo communication.
WCF Endpoint Configuration • Endpoints usually defined using a configuration file associated with the WCF service. They are not defined via attributes, like Contracts. • Example of an endpoint configuration file: • <configuration> • <system.serviceModel> • <services> • <service serviceType="Calculator"> • <endpoint • contractType="Calculator" • bindingType="basicProfileHttpBinding /> • </service> • </services> • </system.serviceModel> • </configuration> • Notes: • <services> element can hold one or more <service> elements. • <serviceType> attribute of the <service> element identiofies the service class implementing the contract. • <service> element can contain one or more <emdpoint> elements. • <contractType> of the <endpoint> element identifies the contract in the ABC paradigm. • <bindingType> of the <endpoint> element identifies the binding in the ABC paradigm.
WCF Client Similar to non-WCF web services, a client is provided with a proxy class, which is uses to formulate it’s requests to the provider service. To generate a proxy class in WCF, you use the svcutil utility, given the service contract for the a particular endpoint. The svcutil utility can also read standard WSDL contracts to generate a proxy class for use by a WCF client.
Interoperability and Migration with Existing Distributed Applications
Appendix A – Other WCF Offerings • Binary Optimized SOAP • Local Behavior - service instance lifetime, concurrent access. • Security • Transactions • Queuing • Messaging Options • Traditional RPC • Asynchronous RPC • Traditional messaging • Message-based RPC
Appendix B – Other Topics • WCF (Indigo) place in an SOA • WCF (Indigo) vs. Enterprise Service Bus (ESB)
Appendix E – Article Resources ARTICLES Microsoft's Indigo Will Advance Web Services http://www.gartner.com/DisplayDocument?doc_cd=126297 Microsoft's Indigo Technology Will Play a Role in Most Enterprises http://www.gartner.com/DisplayDocument?doc_cd=118259 Windows Communication Foundation (Indigo) FAQ http://msdn.microsoft.com/windowsvista/support/faq/communication/ Introduction to Indigo: Early Look http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/introindigov1-0.asp Introduction to Building Windows Communication Foundation Services http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/introtowcf.asp Developing .NET Web Services with Beta 2 http://msdn.microsoft.com/msdnmag/issues/05/04/ServiceStation/ 15 seconds Indigo Programming Model http://www.15seconds.com/issue/050608.htm 15 Seconds : Hosting Indigo Web Services (07/07/05) http://www.internet.com/icom_cgi/print/print.cgi?url=http://www.15seconds.com/issue/050707.htm Microsoft Indigo Architect John Shewchuk http://www.internetnews.com/ec-news/article.php/3357621 Today's Web Service Stack: ASMX 2.0 + WSE 3.0 http://pluralsight.com/blogs/aaron/archive/2005/09/21/14941.aspx
Appendix F – Video Resources VIDEOS MSDN TV: Introduction to Indigo (4/7/05) http://www.microsoft.com/downloads/details.aspx?FamilyID=f3c7ab36-ff95-4b31-a973-970733df0b30&DisplayLang=en MSDN TV: Indigo Security in a Nutshell (4/21/05) http://www.microsoft.com/downloads/details.aspx?FamilyID=cd937782-706f-4e59-b8c0-375287442893&DisplayLang=en What is WinFX -The New Programming Interface Introduced in Windows "Longhorn“ (11/7/03) http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20031107WINFXBA/manifest.xml