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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章