• 为 XPO 通过 WCF 生产分布式应用,配置App.config 或者 Web.config


    为 XPO 通过 WCF 生产分布式应用,配置App.config 或者 Web.config:

    1、服务端配置

     参考:WCF服务安全控制之netTcpBinding的用户名密码验证

                WCF入门教程1——WCF简要介绍    https://www.cnblogs.com/jiekzou/p/5325310.html      各种Binding 的性能比较。

    2、客户端配置

    1)如何 通过   DataStoreClient  通过 DataStoreClient(String)  初始化,则 App或者Web的config文件中必须有 <system.serviceModel> 节。也可以使用异步方式:DataStoreClientAsync(String)。

    <system.serviceModel>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicHttpBinding_IDataStoreService" />
         </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8733/WCFService" binding="basicHttpBinding"
               bindingConfiguration="BasicHttpBinding_IDataStoreService" contract="DevExpress.Xpo.DB.IDataStoreWarpServiceAsync"
                name="BasicHttpBinding_IDataStoreService" />
        </client>
    </system.serviceModel>

    注意:  contract="DevExpress.Xpo.DB.IDataStoreWarpServiceAsync"   也可以使用contract="DevExpress.Xpo.DB.IDataStoreWarpService"    其中  Warp 是加入的,通过服务引用生成的没有这点。

       参考 Devexpress  的一个示例: XPOTestLibrary.sln    (地址忘记!) ,代码如下:

        string bindingName = "BasicHttpBinding_IDataStoreService";    此名称必须在配置文件中有对应 endpoint.

        //IDataStore dataStore = new DataStoreClient(bindingName);     同步

        //XpoDefault.DataLayer = new SimpleDataLayer(dataStore);

        IDataStoreAsync dataStoreAsync = new DataStoreClientAsync(bindingName);      异步

         XpoDefault.DataLayer = new SimpleDataLayer(dataStoreAsync);

    2)直接使用     DataStoreClient(Binding binding, EndpointAddress remoteAddress)  或者        

    DataStoreClientAsync(Binding binding, EndpointAddress remoteAddress)     代码如下:(也否用同步方式)

        BasicHttpBinding binding = new BasicHttpBinding();
        EndpointAddress endpointAddress = new EndpointAddress(new Uri("http://localhost:8734/"));

        IDataStoreAsync dataStoreAsync = new DataStoreClientAsync(binding, endpointAddress);

        XpoDefault.DataLayer = new SimpleDataLayer(dataStoreAsync);

     
  • 相关阅读:
    Tennix — 开源的网球游戏
    Tile Racer — 3D 赛车游戏
    51CTO网管生活
    分割图片的例子 回复 "小熊宝" 的问题
    图解 CSS (5): font 字体
    图解 CSS (9): 列表
    图解 CSS (11): 理解样式表的逻辑
    图解 CSS (8): 浮动、显示、隐藏
    图解 CSS (10): 链接、继承、放缩、鼠标指针、其他(待补充...)
    多线程编程(2) 从 CreateThread 说起
  • 原文地址:https://www.cnblogs.com/hopesun/p/11148106.html
Copyright © 2020-2023  润新知