Building   Windows Communication Foundation based applications

Building Windows Communication Foundation based applications PowerPoint PPT Presentation


  • 334 Views
  • Uploaded on
  • Presentation posted in: General

Agenda. Questions I will make pausesWhat is WCFTerms of WCFPractice 1 creating a simple service and a simple clientPractice 2 creating a service from codePractice 3 various bindings and endpoint configurationProgramming WCFToolsContractPractice 4 contract implementation, object se

Download Presentation

Building Windows Communication Foundation based applications

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


1. Building Windows Communication Foundation based applications

2. Agenda Questions – I will make pauses What is WCF Terms of WCF Practice 1 – creating a simple service and a simple client Practice 2 – creating a service from code Practice 3 – various bindings and endpoint configuration Programming WCF Tools Contract Practice 4 – contract implementation, object serialization Practice 5 – message exchange pattern Session Instancing Practice 6 – service instancing Concurrency Binding Practice 7– various bindings Address Hosting Practice 8 – service hosting Behaviors WCF – what else? Bibliography

3. What is WCF MS idea of SOA common programming model for MS technologies ASMX (ASP.NET web services) .NET Remoting Enterprise Services MSMQ (Message Queuing) WSE (Web Service Enhancements) COM+

4. Terms of WCF Service – collection of endpoints Message Endpoint – point of access to the service ABC Address (WHERE) Binding (HOW) Contract (WHAT) Metadata Bahavior ServiceHost Proxy

5. Communication

6. Endpoint

7. Endpoint ABC

8. Behavior

9. Metadata

10. Hosting

11. Practice 1 – creating a simple service and a simple client System.ServiceModel IStringService StringService App.Config service behaviorConfiguration host baseAdresses endpoint address binding (BasicHttpBinding) contract behaviors Program.cs HTTP Browser WcfTestClient.exe StringServiceClient VS2008 SvcUtil.exe WCF Terms ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/wcf_con/html/3e7e0afd-7913-499d-bafb-eac7caacbc7a.htm http://msdn2.microsoft.com/en-us/library/ms731079.aspx

12. Practice 2 – creating a service from code code vs. configuration WcfServiceLibrary WcfSvcHost.exe

13. Practice 3 – various bindings and endpoint configuration binings NetTcpBinding WsHttpBining endpoint bindingConfiguration

14. Programming WCF designing service contracts implementing service contracts configuring services hosting services creating clients

15. Tools C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\SvcUtil.exe C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\WcfTestClient.exe C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\WcfSvcHost.exe C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\SvcTraceViewer.exe

16. Contract in practice used in code (not in configuration) basics [ServiceContract] [OperationContract] data serializers DataContractSerializer XmlSerializer (uzywany w ASP.NET) [Serializable] is enough [DataContract] [DataMember] [MessageContract] message exchange pattern request-reply one-way ([OneWay]) duplex ([OneWay] + [CallbackContract(typeof(IMyCallbackContract))]) + klient) session correlation of messages between two endpoints that forms a conversation

17. ServiceContract [ServiceContract] public interface IStringService { [OperationContract] string Echo(string message); }

18. Practice 4 – contract implementation, object serialization controlling object serialization [Serializable] [DataContract] [DataMember] (properties as well as fields!) [KnownType] – gives the ability to use polymorphism

19. Practice 5 – message exchange pattern Message exchange pattern request-reply one-way (operation - [OneWay]) duplex (binding has to support it!) operation - [OneWay] service - [CallbackContract(typeof(IMyCallbackContract))]) client implementation of IMyCallbackContract IMyContract service = new MyContractClient(new InstanceContext(new MyCallbackContract()));

20. Session correlates stan a group of messages between a client and a service into a conversation in general (take a look at the last point) session is initiated and closed by the client (unlike in ASP.NET) session ensures the order of processing the messages by the service according to the order in which they were sent by the client session does NOT provide any data storage (as it is in ASP.NET) contract: SessionMode Allowed – service allows the client to begin a session (default) NotAllowed – service does not allow the client to begin session Required – service requires the client to begin session binding: session-based – supports session all service calls in context in one session are processed by the same service object (however, the question is how long the session lasts)

21. Session (2) common uses of session security session reliable session dependence on other mechanisms instancing concurrency special operation types in the context of session instantiating (default) – operations that are NOT instancing have to be executed after an instancing one terminating – no other operation may be executed after a terminating one

22. Instancing controls the lifetime of the service object behavior 1 InstanceContext -> 1 Service (default) ServiceBehavior: InstanceContextMode – how frequent InstanceContext is released PerCall – once per service operation call PerSession – once per session start (until the client closes the session) (default) Single – once per application lifetime (singleton) OpeartionBehavior: RealeaseInstanceMode, ServiceBehavior: ReleaseInstanceOnTransactionComplete – when InstanceContext is released Instancing vs. Session (SessionMode vs. InstanceContextMode) http://msdn2.microsoft.com/en-us/library/ms731193.aspx (the bottom table) ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/wcf_con/html/50797a3b-7678-44ed-8138-49ac1602f35b.htm remember about the session-based binding!

23. Practice 6 – service instancing Session [ServiceContract(SessionMode=SessionMode.Required)] [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)] [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)] [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)] [OperationContract(IsInitiating=true)] [OperationContract(IsTerminating=true)] still have to close the client after excecuting such a method

24. Concurrency controlling the number of threads using the InstanceContext object at the same time behavior ServiceBehavior: ConcurrencyMode Single – max 1 thread per InstanceContext (blocking) Multiple – n threads per InstanceContext (thread-safe implementation!) Reentrant – max 1 message per InstanceContext, but allows reentrence relevant when InstanceContextMode = PerSession, Single

25. Binding defines HOW the service communicates with the client binding elements transaction reliability security encoding (text, binary, MTOM, custom) transport (HTTP, TCP, IPC, P2P, MSMQ, custom) built-in binding abilities – the table http://msdn2.microsoft.com/en-us/library/ms730879.aspx ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/wcf_con/html/2c243746-45ce-4588-995e-c17126a579a6.htm usually defined in configuration (chosen per endpoint!) binding configuration custom binding

26. Binding (2) System-Provided Bindings BasicHttpBinding (HTTP, ASP.NET) WSHttpBinding (HTTP, secure) WSDualHttpBinding (HTTP, duplex) WSFederationHttpBinding (HTTP, WS-Federation, authenticacion, authorization) NetTcpBinding (TCP, binary, cross-machine, secure, reliable) NetNamedPipeBinding (named pipes, binary, on-machine, secure, reliable) NetMsmqBinding (queue – no response, reliable, cross-machine) NetPeerTcpBinding (multimachine, secure) MsmqIntegrationBinding (interoperability MSMQ, cross-machine) Binding elements interoperability (transport protocol, technology) encoding (text, binary, MTOM) security (none, transport, message, mixed) session (none, reliable, security) transactions (yes, no) duplex (yes, no) (requires session support!) streaming (buffered, streamed, streamedRequest, streamedResponse)

27. Praktyka 7 – various bindings Binding NetNamedPipeBinding NetMsmqBinding create a queue essential binding configuration

28. Address there is some theory... (URI, 4 part address...) endpoint must be uniquely identified by an address addresses usually defined in configuration (not in code) service address= baseAddress (host) + address (endpoint) addresses matched on the basis of protocol (http, net.tcp) addresses not using baseAddress (net.msmq, net.pipe) endpoint allows empty address (uses only baseAddress) each two addresses of the same type (protocol) must be different baseAddress=„http://localhost:8080/StringService” enpoint address=„” binding=„basicHttpBinding” contract=„IStringService” enpoint address=„/ws” binding=„wsHttpBinding” contract=„IStringService” examples: http://localhost:8082/StringService net.tcp://localhost:8081/StringService net.pipe://localhost/StringService net.msmq://localhost/private/DictionaryService

29. Hosting hosting possibilities managed application (ex. console) does not need infrastructure during development flexibility managed windows service lifetime controlled by Windows operating system secure execution environment IIS 5.0/6.0 (Internet Information Services) all mechanisms of IIS transport protocol: HTTP IIS 7.0: like WAS WAS (Windows Process Activation Service) Vista / Windows Server 2008 mechanisms of IIS transport protocol: HTTP, TCP, named pipes, MSMQ WcfSvcHost (VS 2008, console) during development

30. Practice 8 – service hosting Hosting IIS Windows Service

31. Behaviors define system semantics development Instancing Concurrency Transactions Impersonation deployment Throttling Metadata exposure

32. WCF – what else? synchronus/asynchronus calls (we only talked about IsOneWay) Faults Bindings WSFederationHttpBinding NetPeerTcpBinding MsmqIntegrationBinding CustomBinding Security Reliable services reliable sessions MSMQ Transactions Streaming P2P Metadata Extending WCF

33. Bibliography MSDN 2008 webcast: Programming the Windows Communication Foundation webcast: Building Secure, Reliable Services with Windows Communication Foundation presentation: Migracja do Windows Communication Foundation (Marcin Celej)

  • Login