zoukankan      html  css  js  c++  java
  • WCF之多个终结点

    1.服务端配置如下(一个Service节点下可有多个endpoint,):

     1  1<system.serviceModel>
     2 2 <services>
     3 3 <service name="Microsoft.ServiceModel.Samples.CalculatorService" behaviorConfiguration="returnFaults">
     4 4 <endpoint address="http://localhost:8000/GIX4" binding ="customBinding"
     5 5 bindingConfiguration="compactBindingConfig" contract="Microsoft.ServiceModel.Samples.ICalculator"/>
     6 6 <endpoint address="basic" binding="basicHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator"></endpoint>
     7 <!--前面加个basic基址就变成了http://localhost:8000/GIX4/basic-->
     8 7 <endpoint address="secure" binding="wsHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator"></endpoint> 
     9 8 <host>
    10 9 <baseAddresses>
    11 10 <add baseAddress="http://localhost:8000/GIX4"/>
    12 11 </baseAddresses>
    13 12 </host>
    14 13 </service> 
    15 14 </services>
    16 15 </system.serviceModel>

    2. 客户端配置:

     1    <system.serviceModel>
     2         <bindings>
     3             <basicHttpBinding>
     4                 <binding name="BasicHttpBinding_ICalculator" />
     5             </basicHttpBinding>
     6             <customBinding>
     7                 <binding name="CustomBinding_ICalculator">
     8                     <binaryMessageEncoding />
     9                     <httpTransport />
    10                 </binding>
    11             </customBinding>
    12             <wsHttpBinding>
    13                 <binding name="WSHttpBinding_ICalculator" />
    14             </wsHttpBinding>
    15         </bindings>
    16         <client>            
    17             <endpoint address="http://localhost:8000/GIX4" binding="customBinding"
    18                 bindingConfiguration="CustomBinding_ICalculator" contract="Calculator.Service.ICalculator"
    19                 name="CustomBinding_ICalculator" />
    20             <endpoint address="http://localhost:8000/GIX4/basic" binding="basicHttpBinding"
    21                 contract="Calculator.Service.ICalculator"
    22                 name="basic" />
    23             <endpoint address="http://localhost:8000/GIX4/secure" binding="wsHttpBinding"
    24                 contract="Calculator.Service.ICalculator"
    25                 name="secure"> <!--加上一个名字-->
    26                 <identity>
    27                     <userPrincipalName value="chenlh@huawei" />
    28                 </identity>
    29             </endpoint>
    30         </client>
    31     </system.serviceModel>

    3.客户端声明如下:

     1 CalculatorClient client = new CalculatorClient("basic"); 

  • 相关阅读:
    使用NPOI导出Excel 并设置Excel样式(合并单元格、行高、宽度、字体、边框、位置)...
    DevExpress GridView 单元格进度条
    c# groupBox 带标题边框,标题居中,重写控件
    COCO数据集下载断断续续后unzip无法解压
    SSD_论文+代码(pytorch)
    开始机器学习
    收藏 —— KVM网络虚拟化
    收藏 —— 教你阅读Python开源项目
    收藏 —— 活动目录讲解
    系统计划 Cron作业 为什么/etc/crontab /etc/cron.d /etc/cron.* 那么多的定义方式????
  • 原文地址:https://www.cnblogs.com/lihongchen/p/3607379.html
Copyright © 2011-2022 走看看