WCF配置文件常用注释

<? xml version = "1.0 " encoding = "utf-8 " ?>

< configuration >

     < system.ServiceModel >

         <!-- services 元素包含应用中驻留的所有service 的配置要求 -->

         < services >

              <!-- 每个服务的配置

             属性说明:

             name - 指定这个service 配置是针对的那个服务, 为一个实现了某些Contract 的服务类的完全限定名

                   ( 名称空间. 类型名),ServiceHost 载入一个服务后,会到配置文件中的<services> 下找有没有

                   name 属性跟服务匹配的<service> 的配置

             behaviorConfiguration - 指定在<serviceBehaviors> 下的一个<behavior>name, 这个特定<behavior>

                                     给这个service 制定了一些行为, 比如服务是否允许身份模拟 -->

              < service name = " 名称空间. 类型名 " behaviorConfiguration = "behavior ">

                   < host >

                       < baseAddresses >

                            <!-- 在此可以定义每种传输协议的baseAddress ,用于跟使用同样传输协议Endpoint 定义的相对地

                    址组成完整的地址,但是每种传输协议只能定义一个baseAddressHTTPbaseAddress 同时是service

                    对外发布服务说明页面的URL -->

                            < add baseAddress = "http://address " />

                       </ baseAddresses >

                       < timeouts ></ timeouts >

                   </ host >

                   <!-- 每个服务可以有多个Endpoint ,下面<endpoint> 元素对每个Endpoint 分别进行配置

                 属性说明:

                 address - 指定这个Endpoint 对外的URI, 这个URI 可以是个绝对地址,也可以是个相对于baseAddress

                           相对地址。如果此属性为空,则这个Endpoint 的地址就是baseAddress

                 binding - 指定这个Endpoint 使用的binding ,这个banding 可以是系统预定义的9binding 之一,

                           比如是basicHttpBinding ,也可以是自定义的customBindingbinding 决定了通讯的类型、

                           安全、如何编码、是否基于session 、是否基于事务等等

                 contract - 指定这个Endpoint 对应的Contract 的全限定名( 名称空间. 类型名) ,这个Contract 应该被

                            service 元素的name 指定的那个service 实现

                 bindingConfiguration - 指定一个binding 的配置名称,跟<bindings> 下面同类<binding>name 匹配

                     behaviorConfiguration - 指定这个endpointbehavior ,指向<behaviors> 下的同样配置名称的<endpointBehaviors>

                 name - Endpoint 的名称,可选属性,每个Contract 都可以有多个Endpoint ,但是每个Contract 对应的

                        多个Endpoint 名必须是唯一的 -->

                   < endpoint address = "URI " binding = "basicHttpBinding " contract = "Contract 全限定名 " bindingConfiguration = "binding " behaviorConfiguration = "String " name = "">

                       <!-- 用户定义的xml 元素集合,一般用作SOAPheader 内容 -->

                       < headers >

                            <!-- 任何xml 内容 -->

                       </ headers >

                   </ endpoint >

              </ service >

         </ services >

 

         < bindings >

              <!-- 指定一个或多个系统预定义的binding ,比如<basicHttpBinding> ,当然也可以指定自定义的customBinding

             然后在某个指定的binding 下建立一个或多个配置,以便被Endpoint 来使用这些配置 -->

              < basicHttpBinding >

                   <!-- 某一类的binding 的下面可能有多个配置,binding 元素的name 属性标识某个binding -->

                   < binding name = "binding ">

                   </ binding >

              </ basicHttpBinding >

         </ bindings >

         <!-- 定义serviceEndpiont 行为 -->

         < behaviors >

              <!-- 定义service 的行为 -->

              < serviceBehaviors >

                   <!-- 一个或多个系统提供的或定制的behavior 元素

                 属性说明:

                 name - 一个behavior 唯一标识,<service> 元素下<endpoint>behaviorConfiguration 属性指向这个name -->

                   < behavior name = " Behavior 名称 ">

                       <!-- 指定service 元数据发布和相关信息

                     属性说明:

                     httpGetEnabled - bool 类型的值,表示是否允许通过HTTPget 方法获取seviceWSDL 元数据

                     httpGetUrl - 如果httpGetEnabledtrue ,这个属性指示使用哪个URL 地址发布服务的WSDL

                                  如果这个属性没有设置,则使用服务的HTTP 类型的baseAddress 后面加上?WSDL -->

                       < serviceMetadata httpGetEnabled = "true " httpGetUrl = "http://URI:port/address " />

                       <!-- 指定验证服务端的凭据 -->

                       < serviceCredentials >

                            <!-- 指定服务端的证书

                         属性说明:

                         storeName - 证书的存储区,可能值为:AddressBookAuthRootCertificateAuthority

                                     Disallowed MyRootTrustedPeopleTrustedPublisher

                         storeLocation - 证书存储位置,可能值为:CurrentUserLocalMachine

                              x509FindType - 查找证书的方式,可能的值:FindBySubjectNameFindByThumbPrintFindByIssuerName......

                              findValue - 对应查找方式的要查找证书的值                  -->

                            < serviceCertificate storeName = " 存储区 " storeLocation = " 存储位置 " x509FindType = "FindBySubjectName " findValue = "server1 " />

                       </ serviceCredentials >

 

                   </ behavior >

              </ serviceBehaviors >

              <!-- 定义Endpiont 的行为 -->

              < endpointBehaviors >

                   <!-- 一个或多个系统提供的或定制的behavior 元素

                 属性说明:

                 name - 一个behavior 唯一标识,<client> 元素下<endpoint>behaviorConfiguration 属性指向这个name -->

                   < behavior name = " Behavior 名称 ">

                       <!-- 指定客户端的凭据 -->

                       < clientCredentials >

                            <!-- 指定客户端的证书

                         属性说明:

                         storeName - 证书的存储区,可能值为:AddressBookAuthRootCertificateAuthority

                                     Disallowed MyRootTrustedPeopleTrustedPublisher

                         storeLocation - 证书存储位置,可能值为:CurrentUserLocalMachine

                              x509FindType - 查找证书的方式,可能的值:FindBySubjectNameFindByThumbPrintFindByIssuerName......

                              findValue - 对应查找方式的要查找证书的值                  -->

                            < clientCertificate storeName = " 存储区 " storeLocation = " 存储位置 " x509FindType = "FindBySubjectName " findValue = "Client1 " />

                            < serviceCertificate >

                                 < authentication certificateValidationMode = "None " />

                            </ serviceCertificate >

                       </ clientCredentials >

                   </ behavior >

              </ endpointBehaviors >

         </ behaviors >

         <!-- 包含客户端跟服务端连接使用到的Endpoint 的配置 -->

         < client >

              <!-- 每个客户端Endpoint 设置

             属性说明:

             address - 对应到服务端这个Endpointaddress

             binding - 指定这个Endpoint 使用的binding ,这个banding 可以是系统预定义的9binding 之一,

                       比如是basicHttpBinding

             contract - 指定这个Endpoint 对应的Contract 的全限定名( 名称空间. 类型名)

             name - Endpoint 的配置名,客户端代理类的构造方法中的endpointConfigurationName 对应到这个name

             bindingConfiguration - 指定客户端binding 的具体设置,指向<bindings> 元素下同类型bindingname

                behaviorConfiguration - 指定这个endpointbehavior ,指向<behaviors> 下的同样配置名称的<endpointBehaviors> -->

              < endpoint address = "URI " binding = "basicHttpBinding " bindingConfiguration = "binding " behaviorConfiguration = "String " contract = "Contract 全限定名 " name = "endpoint 配置名 " >

                   <!-- 用于客户端验证服务端身份, 可选以下一种方式验证服务端 -->

                   < identity >

                       < userPrincipalName ></ userPrincipalName >

                       < servicePrincipalName ></ servicePrincipalName >

                       <!-- 如果客户端验证是windows, 这里指定DNS; 如果是Certificate ,这里指定证书subject name -->

                       < dns ></ dns >

                       < rsa ></ rsa >

                       <!-- 指定服务端证书的公钥

                            属性说明:

                            encodedValue - 服务端证书的公钥的base64 编码,用于加密用户名和密码 -->

                       < certificate encodedValue = ""></ certificate >

                       <!-- 用户指定在客户端证书存储区内的服务端证书

                         属性说明:

                         storeName - 证书的存储区,可能值为:AddressBookAuthRootCertificateAuthority

                                     Disallowed MyRootTrustedPeopleTrustedPublisher

                         storeLocation - 证书存储位置,可能值为:CurrentUserLocalMachine

                              x509FindType - 查找证书的方式,可能的值:FindBySubjectNameFindByThumbPrintFindByIssuerName......

                              findValue - 对应查找方式的要查找证书的值                  -->

                       < certificateReference storeName = " 存储区 " storeLocation = " 存储位置 " x509FindType = "FindBySubjectName " findValue = "Client1 " />

                   </ identity >

              </ endpoint >

         </ client >

     </ system.ServiceModel >

</ configuration >

from:http://www.cnblogs.com/chnking/archive/2008/01/23/1049353.html auhtor:chnking

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值