首页 > 解决方案 > Windows 2008 服务器上的 WCF 服务错误

问题描述

我们在 Windows 2003 服务器上运行了一项 WCF 服务,最近我们迁移到了 Windows 2008 服务器。

当我们调用服务时,我们会收到以下错误。

An error occurred while receiving the HTTP response to 
http://Example.service/HierarchyMgntService/Service.svc. This could be due 
to the service endpoint binding not using the HTTP protocol. This could also 
be due to an HTTP request context being aborted by the server (possibly due 
to the service shutting down). See server logs for more details.

我的 web.config 文件如下所示:

      <?xml version="1.0" encoding="utf-8" ?>
     <configuration>
     <system.web>
     <compilation debug ="true">
    </compilation>
    <authentication mode="None" />
    <httpRuntime maxRequestLength="2097151"  enable = "True" 
    executionTimeout="45"/>
    </system.web>

     <appSettings>

    <add key="MaxThreadsCount" value="3" />
    <add key="CleanupThreadInterval" value="120000" />
    <add key="RequestRetryThreadInterval" value="10000" />
    <add key="InvokeCallsonThread" value="Y" />
    <add key="ThreadKillInterval" value="30" />
  </appSettings>

    <system.serviceModel>
     <services>
      <service name="HierarchyMgntService" behaviorConfiguration="MTServiceBehavior">
        <endpoint name="HIERARCHYMGNTSERVICE" address="http://Example/HIERARCHYMGNTSERVICE/Service.svc" binding="customBinding"
                            bindingConfiguration="HttpBinding" contract="iHierarchyMgnt" />


        <endpoint name="MWServicemexEndpt" address="mex"
           binding="mexHttpBinding"
           contract="IMetadataExchange" />

      </service>
    </services>


    <bindings>
      <customBinding>
        <binding name="HttpBinding"  openTimeout="10:00:00"
                  sendTimeout="10:00:00" receiveTimeout="10:00:00" closeTimeout="10:00:00">
          <binaryMessageEncoding>
            <readerQuotas maxDepth="4194304" maxStringContentLength="2147483647"
                          maxArrayLength="2147483647" maxBytesPerRead="4194304"
                          maxNameTableCharCount="4194304" />
          </binaryMessageEncoding>
          <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
        </binding>
      </customBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="ClientBehavior">
          <dataContractSerializer maxItemsInObjectGraph="10485760"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="MTServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
          <dataContractSerializer maxItemsInObjectGraph="10485760" />
          <serviceThrottling maxConcurrentCalls="75" maxConcurrentSessions="75"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <!-- Below Log entries message will be true when want to debug any issues otherwise it should be False-->
    <diagnostics>
      <messageLogging
           logEntireMessage="False" logMalformedMessages="False"
           logMessagesAtServiceLevel="False" logMessagesAtTransportLevel="False"
           maxMessagesToLog="5000" maxSizeOfMessageToLog="4194304"/>
    </diagnostics>

  </system.serviceModel>

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="messages"
               type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\WCFlogs\Messages.svclog" />
        </listeners>
      </source>
      <source name="System.ServiceModel" switchValue="Warning" propagateActivity="true">
        <listeners>
          <add type="System.Diagnostics.XmlWriterTraceListener"
                name="traceListener"
                initializeData="C:\WCFlogs\Traces.svclog"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

</configuration>

该调用有时会起作用,而有时会失败。有人可以指出问题出在哪里

标签: c#wcf

解决方案


推荐阅读