wcf杂记

  • WCF服务端和客户端如果传递的参数是复杂类型而且没有使用DataContract标签那么客户端对复杂类型的所有的公开属性都可见。
  • 服务端配置文件

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.serviceModel>
    <services>
    <service name="CarRentalSystem.Implementations.CarRentalService" behaviorConfiguration="CarRentalBehaviorConfiguration">
    <host>
    <baseAddresses>
    <add baseAddress="http://localhost:8888/"/>
    </baseAddresses>
    </host>
    <endpoint contract="CarRentalSystem.Contract.ICarRentalService" binding="wsHttpBinding" address="CarRentalService"></endpoint>
    </service>
    </services>

    <behaviors>
    <serviceBehaviors>
    <behavior name="CarRentalBehaviorConfiguration" >
    <serviceMetadata httpGetEnabled="true"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>

    </system.serviceModel>
    </configuration>

  • Host类

    ServiceHost host = new ServiceHost(typeof(CarRentalService));

    host.Opened += new EventHandler(host_Opened);
    host.Open();
    Console.Read();

  • 版本控制:对外的服务发布了一版之后然后对服务进行升级,就是版本控制
  • 问题:wcf什么情况下用不同的序列化的方式DataContract?XmlSerilize
posted @ 2013-10-10 15:21  feidaochuanqing  阅读(135)  评论(0编辑  收藏  举报