更新时间:2021-10-20 21:12:08
那是因为您没有在服务器使用哪个绑定。让我们看一下您的服务器配置:
That would be because you didn't specify on the server which binding to use. Let's take a look at your server config:
在< bindings>
下,您正在为< basicHttpBinding>
,而您将其命名为 name = basicHttpBinding
。另外,您的端点名称是<端点名称= basicHttpBinding ...>
,其绑定是 binding = basicHttpBinding
。 但是不是指您的绑定配置,而是指绑定类型。因此,它实际上使用的是 basicHttpBinding
的默认设置。
Under <bindings>
you are creating a binding configuration for <basicHttpBinding>
, and you are naming it name="basicHttpBinding"
. Also, your endpoint name is <endpoint name="basicHttpBinding" ...>
and its binding is binding="basicHttpBinding"
. However, it's not referring to your binding configuration, but to the binding type. So, it's actually using the default settings for basicHttpBinding
.
要解决此问题,请首先命名端点并绑定配置有所不同。例如,< endpoint name = basicEndpoint ...>
和< binding name = myBasicBinding ...>
。然后,您需要使用以下属性将绑定配置分配给端点: bindingConfiguration = myBasicBinding
。
To fix this, first of all name your endpoint and binding configuration differently. For example, <endpoint name="basicEndpoint" ... >
and <binding name="myBasicBinding" ... >
. Then you need to assign your binding configuration to your endpoint with this attribute: bindingConfiguration="myBasicBinding"
.
这是客户端配置:
<system.web>
<httpRuntime maxRequestLength="32768"/>
</system.web>
<system.serviceModel>
<client>
<endpoint name="basicEndpoint"
address="http://localhost:9502/HCDataService"
binding="basicHttpBinding"
bindingConfiguration="myBasicBinding"
contract="HC.APP.Common.ServiceContract.IHCServiceContract"
behaviorConfiguration="ServiceBehaviour">
</endpoint>
</client>
<bindings>
<basicHttpBinding>
<binding name="myBasicBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ServiceBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
这是服务器配置:
<system.serviceModel>
<services>
<service name="HC.APP.Server.Service.HCDataService" behaviorConfiguration="ServiceBehaviour">
<host>
<baseAddresses>
<add baseAddress="http://localhost:9502/HCDataService"/>
</baseAddresses>
</host>
<endpoint name="basicEndpoint"
address="http://localhost:9502/HCDataService"
binding="basicHttpBinding"
bindingConfiguration="myBasicBinding"
contract="HC.APP.Common.ServiceContract.IHCServiceContract">
</endpoint>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="myBasicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >
<readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
别忘了更新服务参考
在您的客户端上以获取正确的配置。
Don't forget to update service reference
on your client to get the correct config.