WCF 服务绑定采用默认值而不是自定义值 [英] WCF Service Binding taking default values instead of custom values

查看:22
本文介绍了WCF 服务绑定采用默认值而不是自定义值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个 APi,它是一个 WCF 服务.在服务的 web.config 中,我指定了一个自定义 bindong,如下所示:

I have build an APi which is a WCF Service. In the web.config for the service i have specified a custom bindong looking like this:

<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>

通过在端点标记中设置name"属性来告诉配置使用我指定的绑定:

Telling the configuration to use the binding i have specified by setting the "name" attribute in the endpoint tag:

<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"中的默认值.

See. When i create an web reference to the service in VS2008 a app.config are generated. In this app.config the binding used, should be the one specified above. But in the app.config is a default binding with default values in the "maxArrayLength" for instance.

<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 配置,但是为什么所有值都是默认值,我不明白.有人可以提供有关如何自定义绑定值并使其反映在客户端"部分的线索吗?

I can see that the client is using the FxBinding configuration, but why on earth all the values are default, i dont understand. Can anubody give at at clue on how to customize the binding-values and make it reflect on the "client"-part?

如果我更改 app.config 中的手动值,我会得到想要的效果,但是每次更新 webreference 时,VS 只会添加一个具有默认值的新绑定.

If i change the values manualle in the app.config i get the desired effect, but every time the webreference is updated, VS just adds a new binding with the default values.

推荐答案

诸如 maxArrayLength 之类的信息不是 WSDL 的一部分,因此客户端无法推断它而仅采用默认值.

Information such as maxArrayLength is not part of the WSDL, so the client cannot infer it and just takes default values.

这篇关于WCF 服务绑定采用默认值而不是自定义值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆