Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Communication Foundation Part 1 You can reuse these slides but please mention the original source if you want to do so. Speaker: Nguyễn Bá Quang.

Similar presentations


Presentation on theme: "Windows Communication Foundation Part 1 You can reuse these slides but please mention the original source if you want to do so. Speaker: Nguyễn Bá Quang."— Presentation transcript:

1 Windows Communication Foundation Part 1 You can reuse these slides but please mention the original source if you want to do so. Speaker: Nguyễn Bá Quang & Trịnh Minh Cường

2 Agenda WCF Unified Model Simple demo ClientsHosting WCF Architecture Detail Endpoints ABCs and Behaviors

3 Overview and Architecture

4 Unified Model Basic Open Interop Basic Open Interop ASMX Secure Open Interop Secure Open Interop WSE Fast Secure Binary Fast Secure Binary Remoting Queued Txns Queued Txns MSMQ Fast Secure Binary Txns Fast Secure Binary Txns Enterprise Services Image from WCF presentation by Mike Taulty - Vista Developer Launch

5 Unified Model Benefits Programming model Learning curve Consistency Write less code when using multiple technologies FlexibilityEnvironments Productivity in development environment Simplify Automated Integration Testing Deployment options in production Design for distribution, run local

6 WCF Architecture ClientService Message ABCABC AddressBindingContract (Where)(How)(What) Bv Bv Bv Bv ABC Endpoint

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

8 Service Model Layer Influences system operation based on incoming and outgoing messages. Effects of behaviors are local. Messaging Layer Moves messages back and forth and adds transfer semantics. Channels are symmetric. ServiceCode Message Inspector Formatter Behavior Instancing Behavior Security Channel TCP Transport Security Channel TCP Transport Transaction Behavior Formatter Behavior WCF Architecture: Composition & Behaviors

9 3 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)

10 Demo #1: Simple console WCF app 01_WCFServiceLibrary Create WCF service How to test service through web browser How to consumes it 10

11 Client side: Add Service

12 Service Clients Through code or configuration Service knowledge Extract metadata SvcUtil.exe Custom tool Generates code and config Share Types Service, Data, Faults Reusing existing types on the client Set Name and Namespace GSC SSC RSC

13 Service Metadata OperationsTypesAddressesBindingsPolicies Described using WSDLWS-Policy Image from WCF presentation by Mike Taulty - Vista Developer Launch

14 Demo mex: 02_ConsoleWCFWithConfig 14

15 Service Hosting

16 Where Are We? ServiceHostDescription Behaviour EndpointAddressBindingContract Behaviour Operation Behaviour RuntimeListenersSitesExtensions

17 Demo: different type of hostings Quang Self Host IIS Host Windows Service Host 17

18 Where Are We? ServiceHostDescription Behaviour EndpointAddressBindingContract Behaviour Operation Behaviour RuntimeListenersSitesExtensions

19 Address

20 Where Are We? ServiceHostDescription Behaviour EndpointAddressBindingContract Behaviour Operation Behaviour RuntimeListenersSitesExtensions

21 Endpoint Address UriIdentityHeaders

22 Address URI SchemeHostPortPath Port Sharing via HTTP.SYS Port Sharing via HTTP.SYS Port Sharing via TCP Port Sharing Service Port Sharing via TCP Port Sharing Service

23 Binding

24 Where Are We? ServiceHostDescription Behaviour EndpointAddressBindingContract Behaviour Operation Behaviour RuntimeListenersSitesExtensions

25 Bindings How to talk to the service endpoint Binding information categories ProtocolsSecurity Reliable messaging TransactionsEncodingTransport

26 Binding Layers and Elements Bindings are constructed from an ordered set of binding elements Binding elements add channels to the channel stack in the channel factories/listeners

27 Binding Features BindingInteroperabilitySecurity (Default)Session (Default)TransactionsDuplex BasicHttpBindingBasic Profile 1.1None, Transport, Message,None n/a WSHttpBindingWSTransport, Message, MixedNone, Transport, Reliable SessionNone, Yesn/a WSDualHttpBindingWSMessageReliable SessionNone, YesYes WSFederationHttpBindingWS-FederationMessageNone, Reliable SessionNone, YesNo NetTcpBinding.NET 3.0Transport, MessageReliable Session, TransportNone, YesYes NetNamedPipeBinding.NET 3.0TransportNone, TransportNone, YesYes NetMsmqBinding.NET 3.0Message, Transport, BothNoneNone, YesNo NetPeerTcpBindingPeerTransportNone Yes MsmqIntegrationBindingMSMQTransportNoneNone, Yesn/a

28 Configure binding 28 Entirely by code Using code and configuration file Demo how to use WCF Service Configuration Editor.

29 Demo #2 02_ConsoleWCF02_ConsoleWCFWithConfig 29

30 WCF Service Configuration Editor 30

31 Create Your Own Binding Custom Use CustomBinding Fill with binding elements Through code or configuration Inherit Derive from system-provided bindings User-defined Derive from Binding Add your own or system-provided elements

32 Demo 3 Ways to Talk One Way: Datagram-style delivery. Demo 03_OneWay Request-Reply Immediate Reply on same logical thread. 04_Asynchronous Duplex Reply “later” and on backchannel (callback-style) ClientService One Way Request-Reply Duplex (Dual)

33 Contract

34 Where Are We? ServiceHostDescription Behaviour EndpointAddressBindingContract Behaviour Operation Behaviour RuntimeListenersSitesExtensions

35 Contract Types ServiceContractOperationContractDataContractDataMemberFaultContractMessageContractMessageHeaderMessageBodyMember

36 [ServiceContract] Defines the service to be published Can be applied to interfaces and classes PropertiesNameNamespaceProtectionLevelCallbackContractSessionMode

37 [OperationContract] Defines operations provided by the service PropertiesIsOneWay No service exceptions when set to true IsInitiatingIsTerminatingProtectionLevelAction Use “*” to catch all messages OES OEC

38 Data Contracts [ DataContract ] PropertiesName Namespace (Default: http://schemas.datacontract.org/2004/7/[Namespace]) [ DataMember ] PropertiesNameIsRequiredOrder Can be applied to any instance property, field or event Same namespace as the DataContract PDM

39 Collections Collections are interchangeable All list collections of the same type are considered to have the same data contract Same applies to dictionaries of the same type Concrete classes and interfaces [CollectionDataContract] More control over collection serialisation

40 Sharing DataContract ApproachesSvcutil.exe Share the type Reuse an existing type (struct/class/interface) Make sure you set the Name and Namespace SDC RDC

41 FaultContract Exceptions should be explicitly published Security Exception to fault mapping How to raise the fault? Decorate the fault with [DataContract] Decorate the operation contract with [FaultContract] Throw FaultException Throw FaultException How to handle the fault? Catch FaultException Catch FaultException Detail property of the exception is of type TDetail FDC FOC TFE CFE

42 Behaviors

43 Where Are We? ServiceHostDescription Behaviour EndpointAddressBindingContract Behaviour Operation Behaviour RuntimeListenersSitesExtensions

44 Behaviours SBV

45 Demo (Quang) PerCallPerSession 45

46 Demo: SilverLight consume basic web service ADO.net data service 46

47 Questions?


Download ppt "Windows Communication Foundation Part 1 You can reuse these slides but please mention the original source if you want to do so. Speaker: Nguyễn Bá Quang."

Similar presentations


Ads by Google