1 / 32

Windows Communication Foundation

Windows Communication Foundation. a.k.a >>>>>>(WCF - Indigo)<<<<<. Instructor: Mr. Phạm Thi Vương. Students: Đỗ Hồng Hải Đỗ Trường Giang Trần Công Vương. Tổng quan. Introduction Web Service – Oriented Review WCF Fundamentals How to set up WCF Web Service Reference Q&A. Section .

Download Presentation

Windows Communication Foundation

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Communication Foundation a.k.a >>>>>>(WCF - Indigo)<<<<< Instructor: Mr. PhạmThiVương Students: ĐỗHồngHải ĐỗTrườngGiang TrầnCôngVương

  2. Tổngquan • Introduction • Web Service – Oriented • Review WCF Fundamentals • How to set up WCF Web Service • Reference • Q&A

  3. Section Introduction

  4. Đôinétvề WCF • Nềntảng “Communication” giữacácứngdụng • Làmộtphầntrong.Net Framework • Hoạtđộng qua Internet hoặc inter-process

  5. a bit of history Object-oriented 1980s Polymorphism Encapsulation Sub-classing Component-oriented 1990s Location Transparent Tight Coupling Runtime Metadata Service-oriented 2000s Message-based Schema+Contract+Policy Broad Interop

  6. [ServiceContract] class HelloService { [OperationContract] [PrincipalPermission(SecurityAction.Demand, Role = “Adminstrators")] [TransactionFlow(TransactionFlowOption.Mandatory)] [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)] String Hello(String Greeting) {return Greeting;} } <bindings> <wsHttpBinding> <binding name="Binding1“ transactionFlow="true"> <security mode="Message"> <message clientCredentialType="Windows“/> </security> <reliableSession enabled="true" /> </binding> </wsHttpBinding> </bindings> • class HelloService { • [WebMethod] • public String Hello(String Greeting) { • X509CertificateCollection collection = new X509CertificateCollection(); • IntPtr blob = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CRYPTOAPI_BLOB))); • IntPtr data = (IntPtr)((int)blob + • Marshal.SizeOf(typeof(CRYPTOAPI_BLOB))); • … • SeqAckRange range = new SeqAcknRange(id, low, high ); • SeqAckRange[] ranges = { range }; • ReliableQueue.ProcessAcks( ranges ); • … • BeginTransaction (NULL, • ISOLATIONLEVEL_SERIALIZABLE, 0, pITxOptions, • &pITransaction); • … • return Greeting; • } • } class HelloService { [WebMethod] public String Hello(String Greeting) { foreach ( SecurityToken tok in requestContext.Security.Tokens { X509SecurityToken token = tok as X509SecToken } … SeqAckRange range = new SeqAcknRange(id,low,high ); SeqAckRange[] ranges = { range }; ReliableQueue.ProcessAcks( ranges ); … BeginTransaction (NULL, ISOLATIONLEVEL_SERIALIZABLE, 0, pITxOptions, &pITransaction); … return Greeting; } } 20,379 linessecurity 10 lines security 1 code + 2 config (elem.) security 1,804 lines reliable messaging 5,988 lines reliable messaging 0 code + 1 config (elem.) reliable messaging 25,507 linestransactions 25,507 linestransactions 2 code + 1 config (attr.)transactions Total lines 27,321 4,442 lines infrastructure Total lines:3 code (what) + 4 config (how) Total lines 56,296 efficient

  7. Mộtsốđặcđiểmchính • Thốngnhấtphươngthứctraođổithông tin trênnềntảng .NET • Cóthểđượctriểnkhaitrêncácnềntảngkhác • Cóthểsửdụng qua internet, mạng LAN hay giữacác process • Thíchhợpđểpháttriểncácứngdụngphântán • Dễdàngứngdụng, bảotrì, nângcấptrongpháttriểnphầnmềm • Tíchhợpchặtchẽvớicácứngdụngkháctrêncùngnềntảng • Cókhảnăngtựtíchhợpdạngđệquy hay vớicácwebservicekhác • HỗtrợrộngrãicácđặctảpháttriểnWebservice Unified Service Intergration

  8. Kiếntrúc WCF

  9. Section Web service - Oriented

  10. Service-Oriented Requirement Application bắtbuộc State baogồm quảnlý quảnlýbằng Policy Service traođổi giớihạnnhờ Message Exchange Pattern có baogồm Message môtả Contract địnhnghĩa tạonêntừ Schema

  11. Message Message Service Communication Client Service

  12. Endpoint Endpoint Endpoint Endpoints Client Service Message

  13. C C C B B B A A A Address, Binding, Contract Client Service Message Address Binding Contract (Where) (How) (What)

  14. C C C B B B A A A Behaviors Metadata Caller Service Bv Bv Message Bv Bv Address Binding Contract (Where) (How) (What)

  15. C C C B B B A A A Runtime Metadata Client Service Bv Bv Message Bv Bv ServiceHost Proxy Address Binding Contract (Where) (How) (What)

  16. Section Review WCF Fundamentals

  17. address • Thông tin địnhdanhcủa Service • Chỉcómột address duynhấtchomột service

  18. contract • Đơngiảnhóaviệcđặctảcác message vàcôngđoạngửi – nhận • Gồmcácloại: • Service Contract • Operation Contract • Data Contract • Fault Contract • Message Contract

  19. contract • Chứacác operation • Tươngtựnhưmột interface • Chỉrõwebservicesẽtraođổinhữnggì • Serialize WSDL:portType Operation

  20. data contract Wsdl:message • Mộttổhợpđịnhnghĩanhằmthốngnhấtkiểudữliệugiữa server/client • Cóthểthaybằngcáclớpdữliệukhác Wsdl:part Xsd:element

  21. Message Exchange pattern • Đặctảphươngthứctruyềnthông tin • Gồm 3 loại: • Request-reply • One-way (datagram) • Duplex (callback)

  22. behavior • Nằmtrongphạm vi của contract • Mởrộng hay tùybiếncáctínhnăngcủa service • Thamgiavàoquátrìnhkhởitạocác channel

  23. binding • Đặctảkếtnốicủa endpoint • BaogồmnhiềubindingElement – nhiềucáchkếtnốivớiclient

  24. Hosting WCF • IIS • Self-Hosting trongcácứngdụngnền .NET • Console Application • Windows Form • Windows Service • Windows Activation Service (WAS)

  25. Section Demo WCF Web service

  26. set up web service • Thêmreference ServiceModeltrong project – import • TạoServiceContract • ĐịnhnghĩacácOperationContract • Implement interface

  27. set up web service (2) • Done? • Not so fast! • Để Client cóthểkếtnốiđến endpoint, web service cầnkhaibáothêm Metadata

  28. client Add reference Code

  29. Section Reference

  30. Reference Resources • MSDN • CodeProject • Introducing Windows Communication Foundation – Microsoft • Best friend: Google

  31. Caution!!! Q&A

  32. Thank you for listening. ^^

More Related