WCF配置文件結構
WCF配置文件結構:
<system.serviceModel>
<!--服務器端WCF服務配置-->
<services>
<!--使用配置文件啟動元數據交換行為,這樣就可以在瀏覽器中通過配置的地址進行訪問-->
<service behaviorConfiguration="TestBehavior" name="NameSpace.TestClass">
<!--
終結點:終結點由地址、綁定、契約有關,地址定義了服務的位置,綁定定義了服務通信的方式,契約定義了服務的內容
address為空則表示使用基地址
使用配置文件可以為終結點使用的綁定進行定制,即添加 bindingConfiguration 屬性,它的值應與<bindings>配置節中定制的綁定名一致
-->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITest" contract="NameSpace.ITestInterface">
<identity>
<!--只允許本地調用-->
<dns value="localhost"/>
</identity>
</endpoint>
<!--元數據交換-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<!--元數據交換行為配置-->
<behaviors>
<serviceBehaviors>
<behavior name="TestBehavior">
<!--基于HTTP-GET的元數據交換-->
<serviceMetadata httpGetEnabled="true"/>
<!--顯示詳細的異常信息-->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--定制綁定-->
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITest" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<!--服務器端WCF服務配置-->
<services>
<!--使用配置文件啟動元數據交換行為,這樣就可以在瀏覽器中通過配置的地址進行訪問-->
<service behaviorConfiguration="TestBehavior" name="NameSpace.TestClass">
<!--
終結點:終結點由地址、綁定、契約有關,地址定義了服務的位置,綁定定義了服務通信的方式,契約定義了服務的內容
address為空則表示使用基地址
使用配置文件可以為終結點使用的綁定進行定制,即添加 bindingConfiguration 屬性,它的值應與<bindings>配置節中定制的綁定名一致
-->
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITest" contract="NameSpace.ITestInterface">
<identity>
<!--只允許本地調用-->
<dns value="localhost"/>
</identity>
</endpoint>
<!--元數據交換-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<!--元數據交換行為配置-->
<behaviors>
<serviceBehaviors>
<behavior name="TestBehavior">
<!--基于HTTP-GET的元數據交換-->
<serviceMetadata httpGetEnabled="true"/>
<!--顯示詳細的異常信息-->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--定制綁定-->
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITest" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>

浙公網安備 33010602011771號