【问题标题】:Wcf service configuration issueWcf 服务配置问题
【发布时间】:2015-07-14 11:51:29
【问题描述】:

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

错误 1: 已超出传入邮件 (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>

请提出不同机器上服务行为不同的原因。

【问题讨论】:

    标签: wcf wcf-binding


    【解决方案1】:

    您应该在客户端和服务双方使用相同的 bindingConfiguration

    【讨论】:

    • 如果我使用 wcftestclient 进行测试,该怎么做。请告诉我
    • wcftestclient 没有实际使用,只是显示服务还可以
    • 非常感谢。它正在与客户端应用程序一起使用。
    猜你喜欢
    • 2011-02-04
    • 1970-01-01
    • 2011-10-02
    • 2011-04-15
    • 1970-01-01
    • 2020-01-09
    • 2010-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多