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 >