Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Communication Foundation. Agenda How We Got Here ASMX vs WCF Throwdown WCF Contracts Service Data Message Bindings Security Reliability Declarative.

Similar presentations


Presentation on theme: "Windows Communication Foundation. Agenda How We Got Here ASMX vs WCF Throwdown WCF Contracts Service Data Message Bindings Security Reliability Declarative."— Presentation transcript:

1 Windows Communication Foundation

2 Agenda How We Got Here ASMX vs WCF Throwdown WCF Contracts Service Data Message Bindings Security Reliability Declarative Summary

3 From Objects to Services PolymorphismEncapsulationSubclassing Message-basedSchema+Contract Binding via Policy 1980s 2000s Interface-based Dynamic Loading Runtime Metadata 1990s Object-Oriented Service-Oriented Component-Based

4 The Challenge Radically Simplifying Distributed Application Development Development of connected systems remains costly and frustrating Different programming models for different tasks Need for security and reliable messaging Interoperability with applications on other platforms Productive service-oriented programming model needed

5 Windows Communication Foundation Unified framework for rapidly building service-oriented applications

6 What Does WCF Replace? ASMXWSE.NET Remoting COM+ (Enterprise Services) MSMQ

7 WCF……. allows to publish.NET classes as services import from services into.NET classes. includes interoperability code to handle service protocols, type conversion and value marshaling. Allows developers to easily connect their applications to web services.

8 WCF……. supports non-functional requirements (reliable calls, asynchronisity, transactionality, security) comes with predefined adapters can be extended with custom handlers for non-standard scenarios. classes reside mostly in the System.ServiceModel namespace is physically located in the System.ServiceModel.dll assembly.

9 UNDERSTANDING WCF PRINCIPLES

10 Services and Clients ClientService Message Message Uses to communicate between processes.

11 Endpoints ClientService Message EndpointEndpoint Endpoint

12 Address, Binding, Contract ClientService Message AddressBindingContract (Where)(How)(What) Endpoint ABCABC Endpoints ABC

13 WCF Architecture: Messaging Runtime TransportEncoderProtocol(s)TransportEncoderProtocol(s) Client Dispatcher Service Contract and Behaviors Binding Address

14 CONTRACTS The what

15 Three Types of Contracts Service Contract Defines Operations, Behaviors and Communication Shape What does your service do Data Contract Defines Schema and Versioning Strategies What obect data is used Message Contract Allows defining application- specific headers and unwrapped body content Allows control over the SOAP structure of messages

16 Ways to Talk One Way: Datagram-style delivery Request-Reply Immediate Reply on same logical thread Duplex Reply “later” and on backchannel (callback-style) ClientService One Way Request-Reply Duplex (Dual)

17 SERVICE CONTRACTS What does your service do?

18 Service Contract using System.ServiceModel; [ServiceContract] public interface ICalculate { [OperationContract] double Add( double a, double b); [OperationContract] double Subtract( double a, double b); }

19 Service Contract: OneWay [ServiceContract] public interface IOneWayCalculator { [OperationContract(IsOneWay=true)] void StoreProblem (ComplexProblem p); }

20 Service Contract: Duplex Asymmetric [ServiceContract(Session=true, CallbackContract=typeof(ICalculatorResults)] public interface ICalculatorProblems { [OperationContract(IsOneWay=true)] void SolveProblem (ComplexProblem p); } public interface ICalculatorResults { [OperationContract(IsOneWay=true)] void Results(ComplexProblem p); }

21 Service Contract: Duplex Symmetric [ServiceContract(Session=true, CallbackContract=typeof(IChat)] public interface IChat { [OperationContract(IsOneWay=true)] void Talk(string text); }

22 DATA CONTRACTS What object data needs to flow back and forth? This Contract defines the data types that passed in and out to the service.

23 Data Contract [DataContract] public class ComplexNumber { [DataMember] public double Real = 0.0D; [DataMember] public double Imaginary = 0.0D; public ComplexNumber(double r, double i) { this.Real = r; this.Imaginary = i; } }

24 MESSAGE CONTRACTS Defines the mapping between the type and a SOAP envelope

25 MESSAGE CONTRACT SOAP message structure automatically generated by WCF. But Message contracts provide the ultimate control over the formatting of the SOAP messages.(I.e Message Header and Message body). Probably the biggest reason you would need to obtain this level of control is interoperability and controlling security issues. Message contracts are defined by applying the [MessageContract] attribute. You then specify specifics for each message using the [MessageBodyMember] and [MessageHeader] attributes. The following example illustrates these three attributes by defining a simple message contract:

26 Message Contract [MessageContract( HasProtectionLevel=true; IsWrapped = True; ProtectionLevel = ProtectionLevel.None; WrapperName=”Order”) ] public class UserMyMessage { [MessageHeader] public int UserID; [MessageBody] public string UserName; [MessageBody] public string UserPassword; [MessageBody( Name=; Order=;) ] public string UserRole; // Constructors… } It is Strongly Typed Class that is associated with a SOAP message Attribute maps a SOAP Message Header SOAP body element

27 BINDINGS

28 Bindings & Binding Elements Transport IPCMSMQ Custom TCPHTTP Protocol Encoders.NETTX Custom SecurityReliability Binding HTTPTXSecurityReliabilityText Binary Custom

29 Standard Bindings BindingInteropSecuritySessionTXDuplex BasicHttpBindingBP 1.1N, TNNn/a WSHttpBindingWSM, T, XN, T, RSN, Yesn/a WSDualHttpBindingWSMRSN, YesYes WSFederationBindingFederationMN, RSN, YesNo NetTcpBinding.NETT, MT,RSN, YesYes NetNamedPipeBinding.NETTT, NN, YesYes NetPeerTcpBindingPeerTNNYes NetMsmqBinding.NETT, M, XNN, YesNo MsmqIntegrationBindingMSMQTNN, Yesn/a N = None | T = Transport | M = Message | B = Both | RS = Reliable Sessions

30 Bindings & Behaviors: Security Service CBA CBA Client A BC CBA Be Bindings Insert Claims in Messages Behaviors Implement Security Gates

31 Defining Endpoints <endpoint address="Calculator" bindingSectionName="basicProfileBinding" contractType="ICalculator" />

32 Configuring Bindings

33 Custom Bindings

34 Application Service Model Messaging HostingEnvironments ASP.NETASP.NETWPFWPFWinFormWinForm NT Service COM+COM+ TCPChannelTCPChannel HTTPChannelHTTPChannel QueueChannelQueueChannel Secure Channel Secure Channel ReliableChannelReliableChannel Instance Behavior Throttling Behavior Type Integ. Behavior Behavior Transaction Behavior Concurrency Behavior Error Behavior Metadata Behavior BinaryEncoderBinaryEncoder Text/XMLEncoderText/XMLEncoder …… … … …… WCF Summary WASWAS

35 What we cover Message Contract

36 Message Contract:- Default SOAP message format is provided by the WCF runtime for communication between client and service. If it is not meeting your requirements then we can create out own message format. This can be achieved by using “Message Contract Attribute”. Exposing services on a network even an internal network requires security (This is windows!)


Download ppt "Windows Communication Foundation. Agenda How We Got Here ASMX vs WCF Throwdown WCF Contracts Service Data Message Bindings Security Reliability Declarative."

Similar presentations


Ads by Google