【发布时间】:2010-01-13 12:48:45
【问题描述】:
我已经构建了一个 APi,它是一个 WCF 服务。在服务的 web.config 中,我指定了一个自定义绑定,如下所示:
<bindings>
<wsHttpBinding>
<binding name="FxBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
closeTimeout="00:20:00"
openTimeout="00:20:00"
receiveTimeout="00:20:00"
sendTimeout="00:20:00"
messageEncoding="Mtom">
<readerQuotas
maxDepth="64"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
通过在端点标签中设置“名称”属性来告诉配置使用我指定的绑定:
<services>
<service name="Dba.Admanager.Api.ListingServiceContract" behaviorConfiguration="Dba.Admanager.Api.ListingServiceContractBehavior">
<endpoint address="" binding="wsHttpBinding" name="FxBinding" contract="Dba.Admanager.ApplicationController.Api.IListingServiceContract">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
看。当我在 VS2008 中创建对服务的 Web 引用时,会生成一个 app.config。 在此 app.config 中使用的绑定应该是上面指定的绑定。但是在 app.config 中是一个默认绑定,例如“maxArrayLength”中的默认值。
<bindings>
<wsHttpBinding>
<binding name="FxBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://l-aar-00424012.corp.ebay.com/Admanager.Api/ListingServiceContract.svc"
binding="wsHttpBinding" bindingConfiguration="FxBinding" contract="WCFListingServiceContract.IListingServiceContract"
name="FxBinding">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
我可以看到客户端正在使用 FxBinding 配置,但为什么所有的值都是默认值,我不明白。有人可以提供有关如何自定义绑定值并使其反映在“客户端”部分的线索吗?
如果我在 app.config 中手动更改值,我会得到想要的效果,但是每次更新 web 引用时,VS 只会添加一个具有默认值的新绑定。
【问题讨论】:
标签: wcf wcf-binding