配置多个终节点的意义(自己理解):
一个服务可以有多个终节点,网上也经常有人说终节点才是服务的真正的接口,的确如此,当我们为一个服务配置多个终节点时,就表明这个服务可以被以不同的方式访问(不同的绑定等等),我们配置完服务端后,在客户端引用这个服务(引用服务只是为了让你看明白,它生成了什么东西),你会发现客户端生成了两个endpoint。我们再来讲一下,客户端是怎么去调用的,客户端调用服务时,通常会传一个客户端的endpoint的一个name:
ServiceReference1.Service1Client c = new ServiceReference1.Service1Client("WSHttpBinding_IService1");
这样呢,我们根据这个name的endpoint就可以找到它调用的是服务端的哪个服务。

后面我会再讲一下,一个服务配置多个基址(http,tcp)的情况。

服务端配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>   <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>       <system.serviceModel>
      <bindings>
        <wsHttpBinding>
          <binding name="bingding_WS">
            <security mode="None" />
          </binding>
          <binding name="bingding_WS1">
            <security mode="None" />
          </binding>
        </wsHttpBinding>
      </bindings>
      
      <services>
        <service behaviorConfiguration="MyBehavior"
          name="WcfService1.Service1">
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:8001/"/>
            </baseAddresses>
          </host>
          <endpoint address="HelloService" binding="wsHttpBinding" bindingConfiguration="bingding_WS" contract="WcfService1.IService1"></endpoint>
          <endpoint address="HelloService1" binding="wsHttpBinding" bindingConfiguration="bingding_WS" contract="WcfService1.IService1"></endpoint>          
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="MyBehavior">
            <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点-->
            <serviceMetadata httpGetEnabled="true" httpGetUrl="false" />
            <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
            <serviceDebug includeExceptionDetailInFaults="false"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
    </system.serviceModel>  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  
</configuration>

客户端配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IService1">
                    <security mode="None" />
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8001/HelloService" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="WSHttpBinding_IService1" />
            <endpoint address="http://localhost:8001/HelloService1" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
                name="WSHttpBinding_IService11" />
        </client>
    </system.serviceModel>

</configuration>

点我下载源码 (WCF一个服务配置多个终节点.rar)系统有问题,后面上传。

WCF配置多个终节点的更多相关文章

  1. WCF学习第二篇:WCF 配置架构。这有助于对wcf配置的理解和记忆

    使用 Windows Communication Foundation (WCF) 配置元素,您可以配置 WCF 服务和客户端应用程序. 可以使用配置编辑器工具 (SvcConfigEditor.ex ...

  2. WCF配置详解

    前面一篇文章<WCF 学习总结1 -- 简单实例> 一股脑儿展示了几种WCF部署方式,其中配置文件(App.config/Web.config)都是IDE自动生成,省去了我们不少功夫.现在 ...

  3. 编写WCF服务时右击配置文件无“Edit WCF Configuration”(编辑 WCF 配置)远程的解决办法

    原文:编写WCF服务时右击配置文件无“Edit WCF Configuration”远程的解决办法 今天在看<WCF揭秘>书中看到作者提出可以在一个WCF Host应用程序的App.Con ...

  4. VMware workstation虚拟集群实践(1)—— 配置集群多节点互信

    一. 简述 节点互信,是集群管理的基本操作之一.节点互信是通过SSH协议的公钥密钥认证来代替密码认证来实现的.对于单点批量管理多个节点,多个节点之间相互通信来说,配置SSH单方向信任,或者互信十分必要 ...

  5. WCF 4.0 如何编程修改wcf配置,不使用web.config静态配置

    How to programmatically modify WCF without web.config setting WCF 4.0 如何编程修改wcf配置,不使用web.config静态配置 ...

  6. MS对WCF配置中security节点的解释

    摘录地址:http://msdn.microsoft.com/zh-CN/library/azure/ms731347 <basicHttpBinding> 的 <security& ...

  7. 基于net.tcp的WCF配置实例解析(转)

    http://www.cnblogs.com/scy251147/archive/2012/11/23/2784902.html 原文 本文主要通过文件配置来讲解如何编写一个基于net.tcp的Win ...

  8. WCF配置后支持通过URL进行http方式调用

    最近遇到一个小型项目,主要就是通过手机写入NFC信息,思考许久后决定就写一个简单的CS程序来搞定这个问题,可是当涉及到手机和PC通信的时候首先考虑到的就是IIS,同时因为数据库是SQLite,思前想后 ...

  9. WCF配置心得

    根据蒋金楠老师的博文所说的, WCF的终结点有三个要素组成,分别是地址(Address).绑定(Binding)和契约(Contract),简记可写成Endpoint = ABC. 地址:地址决定了服 ...

随机推荐

  1. Objective-C中的浅拷贝和深拷贝

    浅拷贝 浅拷贝就是对内存地址的复制,让目标对象指针和源对象指向同一片内存空间.如: char* str = (char*)malloc(100); char* str2 = str; 浅拷贝只是对对象 ...

  2. CALayer1-简介

    一.什么是CALayer * 在iOS系统中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个文本输入框.一个图标等等,这些都是UIView. * 其实UIView之所以 ...

  3. Java8新特性——StreamAPI(一)

    1. 流的基本概念 1.1 什么是流? 流是Java8引入的全新概念,它用来处理集合中的数据,暂且可以把它理解为一种高级集合. 众所周知,集合操作非常麻烦,若要对集合进行筛选.投影,需要写大量的代码, ...

  4. 《DSP using MATLAB》示例9.3

    增采样操作是时变的.

  5. FastAdmin 开发时出错的调试

    第一步:打开 FastAdmin Debug 打开 Debug. 第二步:打开浏览器控制器 打开浏览器控制器,并按 F5 重新加载页面. 第三步:在 network 查看详细错误信息 点击红色链接,可 ...

  6. Hibernate Cannot release connection 了,有办法解决!

      问题:    系统采用Spring MVC 2.5 + Spring 2.5 + Hibernate 3.2架构,其中数据源连接池采用的是Apache commons DBCP.问题是这样的,系统 ...

  7. MariaDB主从半同步复制详解

    半同步复制(Semisynchronous replication) 介于异步复制和全同步复制之间,主库在执行完客户端提交的事务后不是立刻返回给客户端,而是等待至少一个从库接收到并写到relay lo ...

  8. UVA-11292Dragon of Loowater

    /* The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into ...

  9. 新版台式机安装win7操作系统

    1.进入bios设置-----authentication选项中的secure boot设置为disabled2.在boot options选项中launch csm设置为always 3.在boot ...

  10. linux加程序是否当掉检测脚本

    cd $(dirname $) source ~/.bash_profile SYSTEM_TIME=`date '+%Y-%m-%d %T'` count=`ps -ef |grep "p ...