【架构之路之WCF全析(二)】--服务配置部署详解

        上篇文章主要讨论了WCF的基本内容,其中包括WCF的术语、创建方法及WCF在开发过程中使用的意义,它不仅能够提供程序之间的通信,而且还能提供程序和数据间的通信,WCF提供了多样化的程序之间的通信,不仅支持App的通信而且还支持web与应用程序之间的通信,可谓是功能强大。虽然上文讨论了WCF的基本使用方法,并做了很多Demo,但是都只是关于WCF的创建和调用的,今天来看看WCF的配置方法。
WCF 配置导图


      上图整理了服务配置过程中所用到的基本的元素,大致的步骤主要是首先要在调用服务的程序集中添加服务的一个引用,然后添加一个service并指定服务的名称、终结点,如果添加了behavior(行为)的配置,那么也需要添加一个behaviorConfiguration的配置信息。在添加一个service时会在其中指定终结点的信息,终结点说的就是服务的具体信息访问方式,在终结点中添加服务address及binding信息和contract(服务契约)信息等。在endpoint中添加的binding只是指定了服务绑定的访问方式,例如:basicHttpBinding等,真正的binding配置是需要在另外的binding中添加的,添加好后需要配置在endpoint的bindingConfiguration。下面看一个服务在客户端部署配置的示例。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <system.serviceModel>

    <!--The bindings configuration
	We deployed the basichttpbinding.
	I added a binding that name is binding1.
	The binding1 used the security.
	-->
    <bindings>
      <basicHttpBinding>
        <binding name="binding1">
          <security mode="Message">
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

    <!--The behaviors configuration
	I added a serviceBehavior that has nothing configuration in.
	-->
    <behaviors>
      <serviceBehaviors>
        <behavior name="service1_behavior">
          
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <!--The services configuration
	I added a service that behaviorConfiguration is service1_behavior.
	This service has an endpoint that added the property and the binding.
	-->
    <services>
      <service name&#
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值