zoukankan      html  css  js  c++  java
  • EndpointContracts

    In WCF, all services expose constracts. The contract is a platform-neutral(平台无关的) and standard way of describing what the service does. WCF defines four types of contracts.

    Service contracts
        Describe which operations the client can perform on the service.
    Data contracts   
        Define which data types are passed to and from the service. WCF defines implicit (隐式的)contracnts for built-in types such as int and stirng,  but we can define explicit data contracts.
    Fault contracts
        define which errors are raised by the service, and how the service handles and propagates (繁殖,传送)errors to its clients.
    Message contracts
        Allow the service to interact directly with messages. Message contracts can be typed or untyped, and are useful in interoperability cases and when there is an existing message format you have to comply with. as a WCF developer, we should use message contracts only rarely. :)

    Example: defining and implementing a service contract

    [ServiceContract]
    interface IMyContract
    {
        [OperationContract]
        string Hello();

        //will not be part of the contract
        string otherHello();
    }

    public class MyService:IMyContract
    {
        public string Hello()
        {
            return "this is a WCF Service";
        }

        //this method is not exposed as a service.
        public string otherHello()
        {
            return "can not call this method over WCF";
        }
    }


    Names and namespaces
        we can and should define a namespace for our contract. if it 's unspecified, the contract namespace defaults to http://tempuri.org. we can use Namespace property of the ServiceContract to provide a namespace.
    [ServiceContract(Namespace="myspace")]
        By default, the exposed name of the contract will be the name of the interface used. However, you could use an alias for a contract to expose a different name to the clients using the name property of the servicecontract
    [servicecontract(Name="IMyContract")]
    interface IMyOtherContract
    {...}
        In similar manner, the name the publicly exposed operation defaults to the method name, but u can use the Name property ot the operationContract to alias it to a different publicly exposed name:
    [OperationContract(Name="SomeOperatin")]
        string Hello();
  • 相关阅读:
    A.3.1. 与MySQL客户端库的链接问题
    c++ mysqlclient library linkage problem Stack Overflow
    找房 爱合住, ihezhu.com
    21.4.5.1. MySQL Connector/C++ Connecting to MySQL
    如何对链接了mysqlclient的程序静态编译?
    分享:[组图] 科技圈最具权势 25 大女工程师
    linux 静态链接 mysql glibc 库的悲催过程 mango的日志 网易博客
    /usr/bin/ld: cannot find lgcc_s 问题解决小记
    « 静态编译的MySQL易挂起 »
    SQL C++代码自动生成器(sql2class)介绍 Newzai的专栏 博客频道 CSDN.NET
  • 原文地址:https://www.cnblogs.com/Winston/p/1155730.html
Copyright © 2011-2022 走看看