Wcf 服务配置问题

Wcf service configuration issue

我创建的 WCF 服务出现问题。问题并非出现在所有客户端上 - 即在某些系统上它在其他系统上不工作。

错误一: 已超过传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

错误2: 在某些系统上,操作合同未正确公开。操作合同上出现红色符号。并且无法使用 wcftestclient 调用它。

配置文件:

<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" >
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
    <services>
      <service name="ExternalService.Service.MyDashboardService">
        <host>
          <baseAddresses>
            <add baseAddress = "http://****/ExternalService.Service/MyDashboardService/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding" contract="ExternalService.ServiceInterface.IMyDashboardService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
 <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior>
                       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                      <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

现在我在 wcftestclient 中获取错误 1 ​​的客户端配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IMyDashboardService" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://****/ExternalService.Service/MyDashboardService/"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyDashboardService"
                contract="IMyDashboardService" name="BasicHttpBinding_IMyDashboardService" />
        </client>
    </system.serviceModel>
</configuration>

服务运行时的客户端配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IMyDashboardService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    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>
        <client>
            <endpoint address="http://****/ExternalService.Service/MyDashboardService/"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyDashboardService"
                contract="IMyDashboardService" name="BasicHttpBinding_IMyDashboardService" />
        </client>
    </system.serviceModel>
</configuration>

请指出不同机器上服务行为不同的可能原因。

你应该在客户端和服务端使用相同的绑定配置