Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Communication Foundation

Similar presentations


Presentation on theme: "Windows Communication Foundation"— Presentation transcript:

1

2 Windows Communication Foundation
António Cruz Freelancer (SAPO/PT.COM)

3 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

4 What Is the Windows Communication Foundation?
Yesterday: Remoting COM D/COM WSE MSMQ ASMX COM+ Many confusing and complicated options The Windows Communication Foundation, which was code-named “Indigo,” is a technology by which pieces of software can communicate with one another. There are many other such technologies, including COM and DCOM, RMI, MSMQ, and WebSphere MQ. Each of those works will work well in a particular scenario, not so well in others, and is of no use at all in some cases. The Windows Communication Foundation is meant to work well in any circumstance in which software entities must be made to communicate with one another. In fact, it is meant to always be the very best option: It provides performance that is about as good as, if not better than, any other alternative; it offers at least as many features and probably several more; and it will certainly be the easiest solution to program. WCF is a software factory template for software communication. It consists of a DSL, called the Service Model, and a class framework, called the Channel Layer. WCF is a complete infrastructure for service-oriented programming. Now: Windows Communication Foundation One simple choice that is always the best option

5 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

6 How Does It Work? Data Service Model Metadata Channel Layer Messages
Address, Binding, Contract, and Behaviors Metadata Concretely, the Windows Communication Foundation consists of a number of class libraries within the .NET 3 Framework. The most important of those class libraries are the Service Model and the Channel Layer. The Service Model provides you with a small, simple language for modeling how you want your software to communicate. In the language of the Service Model, a piece of software that responds to communications over a network is a service, a service has one or more endpoints, and each endpoint consists of an address (where), a binding (how), and a contract (what). The address defines where the service is located. The binding specifies the set of protocols that it uses to communicate. Contracts define the messages that services can send and receive. At runtime, the Windows Communication looks at the binding that you have defined and assembles, from the Channel Layer, a stack of channels that implement the protocols specified by the binding that you chose. Then, when you have data to send, the Windows Communication Foundation translates your data into a message, and passes the message through the stack of channels it has assembled, so that your message is send on its way in accordance with the protocols identified by your binding. Messages that are received are decoded by the channel stack, and translated into the data that you are expecting. Implementations of new protocols can readily be added to the channel layer. Thus, the Windows Communication Foundation protects your investment by allowing you to continue to use the same simple programming framework provided by the Service Model with any communication protocol you may encounter. Addresses, bindings and contracts defined with the Service Model are all automatically described in metadata, which by default, is in the form of the standard Web Services Description Language. By virtue of the metadata, developers of client application can learn about the endpoints of a service, find out the address, binding and contract of each of those endpoints. They are able to generate client code for communicating with the service from that information provided by the metadata. However, the Service Model language has an additional element that one can use in defining how a piece of software is to communicate that does not surface in the metadata: behaviors. Behaviors are used to control how messages are handled internally, such as whether new instances of your classes are constructed to handle each incoming data, or whether all of the incoming data is sent to the same instance of your classes. It is because such internal processing details don’t affect how a client and a server communicate with one another that behavior options are not included in the metadata for a service. Channel Layer Protocols, Encoders, and Transports Messages

7 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

8 How Do I Use It? Service Contract Definition Contract Implementation
public interface IMyInterface { [OperationContract] public MyOutputType MyMethod(MyInputType myData); } Service Contract Definition [ServiceBehavior(InstanceContextMode=Single] public class MyService: IMyInterface { public MyOutputType MyMethod(MyInputType myData) { //my code } Contract Implementation (Service Type) The development of a Windows Communication Foundation service begins with a developer defining a contract. That is done by writing an interface in a .NET programming language, and then adding attributes from the Service Model that designate the interface as a Windows Communication Foundation contract, and one or more of the methods as being included in the contract. The next step is to implement the contract, which is done simply by writing a class that implements the interface. A class that implements an interface that is designated as a Windows Communication Foundation contract is called a “service type.” How the Windows Communication Foundation conveys data to and from the service type from the outside can be controlled by adding behaviors to the service type definition using the ServiceBehavior attribute. For example, the instance context mode attribute shown here controls whether all incoming data is sent to a new instance of the service type, or to a single instance, amongst other options. Finally, an administrator configures endpoints for the service by associating an address and a binding with the contract and service type provided by the programmer. The configuration of endpoints is defined in a regular .NET configuration file, but a configuration editor is provided so that administrators don’t have to write configuration XML. <service name=“MyService”> <endpoint address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” /> <service/> Endpoint Configuration

9 Self-Host within any .NET process:
How do I Deploy It? Web Host within IIS: For HTTP services on Windows XP® SP2 & WS2K3 For any service on Windows Vista® and Windows Server® “Longhorn” Proven reliability, scalability, and security Requires a .svc file to identify the Service Type Self-Host within any .NET process: Available for any service Console apps, windowed apps, .NET NT Services …

10 Building a Simple Service and Client

11 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

12 You can choose a pre-defined binding:
All About Bindings You can choose a pre-defined binding: <endpoint name=“MyService” address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” /> NetPeerTcpBinding NetMsmqBinding NetNamedPipeBinding NetTcpBinding WSHttpBinding BasicHttpBinding Binding .NET Peer  Peer .NET.NET via MSMQ .NET.NET across processes Secure, reliable duplexed Basis for WS-* interop Supports WS-Security, WS-RM, WS-Tx Basic Profile 1.1 Interop and Integration w/ASMX Purpose

13 You can customize a pre-defined binding
All About Bindings You can customize a pre-defined binding <services> <service name=“MyService”> <endpoint address=“MyAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/> </services> <bindings> <wsHttpBinding> <binding name=“MyReliableBinding”> <reliableSession enabled=“true” ordered=“true” </binding> </wsHttpBinding> </bindings>

14 You can define custom bindings
All About Bindings You can define custom bindings <?xml version=“1.0” encoding=“UTF-8” ?> <configuration> <system.serviceModel> <services> <service name=“MyService”> <endpoint address=“MyAddress” binding=“customBinding” bindingConfiguration=“MyCustomBinding” contract=“IMyInterface” /> </service> </services> <bindings> <customBinding> <binding name="MyCustomBinding"> <reliableSession advancedFlowControl="true” /> <security authenticationMode=“Kerberos” /> <binaryMessageEncoding /> <tcpTransport maxMessageSize=“ " /> </binding> </customBinding> </bindings> </system.serviceModel> </configuration>

15 Reliability

16 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

17 All About Addresses The scheme portion of an address corresponds to the transport protocol: NetNamedPipeBinding NetMsmqBinding NetTcpBinding BasicHttpBinding, WSHttpBinding Binding net.pipe://… net.msmq://… net.tcp://… Scheme IPC – Interprocess communication The schemes clearly indicate which protocols have been standardized.

18 An endpoint address is relative to a base address:
All About Addresses An endpoint address is relative to a base address: <services> <host> <baseAddresses> <add baseAddress=" </baseAddresses> </host> <service name=“MyService”> <endpoint address=“MyEndpointAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/> </services> For a Web-Hosted service, the base address is that of its virtual directory

19 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

20 All About Contracts Look again at this service contract:
public interface IMyInterface { [OperationContract] public MyOutputType MyMethod(MyInputType myData); } How do MyOutputType and MyInputType get serialized into messages? Serialization is done by DataContractSerializer by default Handles “built-in” .NET Framework types automatically User-defined types require Data Contracts: [DataContract] public class MyDataContract { [DataMember] public string MyField; } Can opt for the older, slower XmlSerializer: [ServiceContract] [XmlSerializerFormat] public interface IMyInterface

21 WCF in a Nutshell Externally visible, per-endpoint Opaque,
per-service, endpoint or operation Address Binding Contract Behavior HTTP Transport WS-Security Protocol Request/ Response Instancing Behavior Concurrency Behavior Peer Transport net.p2p://... Throttling Behavior TCP Transport WS-RM Protocol net.tcp://... Metadata Behavior NamedPipe Transport WS-Coord Protocol net.pipe://... One-Way Error Behavior Transaction Behavior MSMQ Transport Duplex Channel net.msmq://... Custom Behavior Security Behavior Duplex Custom Transport Custom Protocol xxx://...

22 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

23 WCF Transaction Managers
Lightweight Transaction Manager (LTM) Single AppDomain, single durable resource, multiple volatile, one service, maximum performance. Distributed Transaction Coordinator (DTC) Transactions across process and network, uses OleTx or WS-AT, multiple services, flows client and services transactions, system service. Kernel Transaction Manager (KTM) Vista/Longhorn only, transactional file system (TxF) & registry (TxR), uses LTM (multiple volatile resources, one service).

24 Transactions

25 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

26 All About Security Authentication Authorization
A message may incorporate a security token The security token has claims about the sender The type of security token is configured with the binding Built-in support for these token types: Windows (Kerberos or NTLM) Username (a user name & a password) X.509 certificate CardSpace tokens SAML tokens Can add support for custom token types Authorization Authorization configured w/ServiceAuthorizationBehavior Authorization options: For users authenticated using Windows tokens: Principal Permissions ASP.NET Role Provider For users authenticated using any sort of token: a ServiceAuthorization manager

27 Message-Level Security

28 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

29 All About Management Integrated Management Management Model Tools
Microsoft Operations Manager 2005 Management Pack Integrated Management Management Model Microsoft Management Model Designer Tools CIM Studio ScriptOMatic PowerShell Configuration Editor Trace Viewer PerfMon PowerShell CmdLet Instruments (Data & Control Points) Configuration System WMI Provider Tracing and Logging Performance Counters Management Interface

30 Agenda What Is the Windows Communication Foundation? How Does It Work?
How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

31 All About Integration Client Service Integration Strategy ASMX WCF WCF
Configure WCF components to use BasicHttpBinding Remoting WCF WSE 2 WCF Remoting WSE 2 Upgrade Remoting & WSE 2 components to WCF WCF WSE 3 WSE 3 WCF For HTTP, use properly configured WSHttpBinding For TCP, custom TCP transport sample on NETFX3.com WCF COM+ Use COMSVCConfig.exe to wrap COM+ app w/WCF endpoint COM WCF Service Monikers

32 All About Extensibility
Contract Contract WSDL Exporter Client Code parameters Service Type parameters Operation Invoker Parameter Inspector Parameter Inspector Message Formatter Message Formatter Message Inspector Instance Provider Typed Proxy Message Inspector Dispatcher Operation Selector Channel Custom Channel Custom Channel Channel Channel Custom Channel Custom Channel Channel Transport Channel byte[] Transport Channel byte[] Encoder Encoder Custom Transport Custom Encoder Custom Encoder Custom Transport * Added by configuring the runtime with behaviors * Added by adding binding elements to the binding

33 REST and POX extensibility

34 Summary What Is the Windows Communication Foundation?
How Does It Work? How Do I Use and Deploy It? Bindings Addresses Contracts Transactions Security Management Integration and Extensibility

35 Links http://wcf.netfx3.com/ http://blogs.msdn.com/drnick/
António Cruz Freelancer (SAPO/PT.COM)


Download ppt "Windows Communication Foundation"

Similar presentations


Ads by Google