zoukankan      html  css  js  c++  java
  • WCF

    1. WCF VS Web Service

    Difference between WCF and Web service

    Web service is a part of WCF. WCF offers much more flexibility and portability to develop a service when comparing to web service. Still we are having more advantages over Web service, following table provides detailed difference between them.

    FeaturesWeb ServiceWCF
    Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service
    Programming [WebService] attribute has to be added to the class [ServiceContract] attribute has to be added to the class
    Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client
    Operation One-way, Request- Response are the different operations supported in web service One-Way, Request-Response, Duplex are different type of operations supported in WCF
    XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespace is used for serialization
    Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom XML 1.0, MTOM, Binary, Custom
    Transports Can be accessed through HTTP, TCP, Custom Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
    Protocols Security Security, Reliable messaging, Transactions

     2. Bindings 和 Behavior

    BindingDescription
    BasicHttpBinding Basic Web service communication. No security by default
    WSHttpBinding Web services with WS-* support. Supports transactions
    WSDualHttpBinding Web services with duplex contract and transaction support
    WSFederationHttpBinding Web services with federated security. Supports transactions
    MsmqIntegrationBinding Communication directly with MSMQ applications. Supports transactions
    NetMsmqBinding Communication between WCF applications by using queuing. Supports transactions
    NetNamedPipeBinding Communication between WCF applications on same computer. Supports duplex contracts and transactions
    NetPeerTcpBinding Communication between computers across peer-to-peer services. Supports duplex contracts
    NetTcpBinding Communication between WCF applications across computers. Supports duplex contracts and transactions

    Binding 是和behavior相关,是How的操作;Simple definition for Binding describes how the client will communicate with service。

    3. EndPoint

     

    4. Tips

    • Always create the service with Interface->Implementation format, mention the contract in Interface.
    • Define the service in Class library and refer the class library in Host project. Don’t use service class in host project.
    • Change the instance mode to per call as default.
    • Always catch exception using try/catch block and throw exception using FaultException < T >.
    • Logging and Include exception should be enable while compiling the project in debug mode. While in production deployment disable the logging and Include exception details.

    5. Contact 和 Service Host

      1. Mainly there are four types of contracts available in WCF: 

        a. Service Contract

        b. Data Contract

        c. Message Contract

        d. Fault Contract

      2. Services can be hosted or executed, so that it will be available to everyone accessing from the client. WCF service can be hosted by following mechanism

      • IIS

        Internet information Service provides number of advantages if a Service uses Http as protocol. It does not require Host code to activate the service, it automatically activates service code.

      • Windows Activation Service

        (WAS) is the new process activation mechanism that ships with IIS 7.0. In addition to HTTP based communication, WCF can also use WAS to provide message-based activation over other protocols, such as TCP and named pipes.

      • Self-Hosting

        WCF service can be self hosted as console application, Win Forms or WPF application with graphical UI.

      • Windows Service

        WCF can also be hosted as a Windows Service, so that it is under control of the Service Control Manager (SCM).

    6. Message and Channel

      1. WCF Message --  is the unit of data exchange between client and service. It consists of several parts, including a body and headers.

      2. WCF Runtime -- WCF runtime is the set of object responsible for sending and receiving message. For example formatting the message, applying security and transmitting and receiving message using various protocol.

      3. Channels -- Channels are the core abstraction for sending message to and receiving message from an Endpoint. 大致分为以下两种:

        a. Transport Channels -- Handles sending and receiving message from network. Protocols like HTTP, TCP name pipes and MSMQ.

        b. Protocol Channels -- Implements SOAP based protocol by processing and possibly modifying message. e.g. WS-Security and WS-Reliability.

    7. WCF Client

      1. A client application is a managed application that uses a WCF client to communicate with another application.

    8. WCF Architecture

      

    9. 

    http://www.wcftutorial.net/Contracts-and-Service-Host.aspx

  • 相关阅读:
    04 UUID
    MD5加密算法(信息摘要算法)、Base64算法
    03 MD5加密、Base64处理
    MVC分层思想、SSM编程架构
    1网络编程基本概念
    Tomcat闪退的解决办法
    win10下的jdk1.8安装
    枚举练习
    1000元买物品分配
    win10解决vc++6.0不兼容问题方法
  • 原文地址:https://www.cnblogs.com/qijiage/p/3376560.html
Copyright © 2011-2022 走看看