2013-06-18 79 views
1

我有一個WCF服務,在我的本地機器上託管時工作,但在服務器上使用IIS託管時無法工作。WCF傳輸錯誤

未處理的通信則拋出異常

。 「接收到對{url}的HTTP響應時發生錯誤此 可能是由於服務端點綁定未使用HTTP 協議造成的,也可能是由於服務器中止了HTTP請求上下文 (可能由於到服務關閉)。有關更多詳細信息,請參閱 服務器日誌。「

內部異常是

「的基礎連接已關閉: 接收發生意外的錯誤」。

我已啓用跟蹤,但對我的錯我真的找不到任何我能在那裏看到,幫助了我。此外,我似乎有關於這個問題的其他線索,但似乎沒有任何幫助。

服務器正在使用https我不禁想到這是問題所在。當我使用http在本地運行它時。一切工作正常。

這些調用正在檢索非常大量的數據,但我無法提供幫助。

任何人都可以請幫助我嗎?

的Web.Config

<appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="2147483647"/>  
    </system.web> 
    <system.serviceModel> 
    <diagnostics> 
     <messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000"></messageLogging> 
    </diagnostics> 
    <services> 
     <service name="Logistics.Wcf.LogisticsService" behaviorConfiguration="serviceBehavior" >   
     <endpoint address="soap" binding="basicHttpsBinding" contract="Logistics.Wcf.ILogisticsService"></endpoint> 
     <!--<endpoint address="rest" binding="webHttpBinding" contract="Logistics.Wcf.ILogisticsService" behaviorConfiguration="restBehavior"></endpoint>--> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="serviceBehavior"> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="restBehavior"> 
      <webHttp helpEnabled="true"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <bindings>  
     <basicHttpsBinding> 
     <binding name="basicHttpsBinding" 
      closeTimeout="00:15:00" 
      openTimeout="00:15:00" 
      receiveTimeout="00:15:00" 
      sendTimeout="00:15:00" 
      maxBufferSize="2147483647" 
      maxBufferPoolSize="2147483647" 
      maxReceivedMessageSize="2147483647" 
      > 
      <security> 
      <transport clientCredentialType="None"></transport> 
      </security> 
      <readerQuotas maxDepth="2147483647" 
      maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647" /> 
     </binding> 
     </basicHttpsBinding> 

    </bindings> 
    <protocolMapping> 

     <add binding="basicHttpsBinding" scheme="https"/> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true"/> 
    </system.webServer> 
    <connectionStrings> 
    <add name="LogisticsEntities" connectionString="metadata=res://*/LogisticsModel.csdl|res://*/LogisticsModel.ssdl|res://*/LogisticsModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=hertz1105\devl;initial catalog=Logistics;user id=airclic2;password=air123_***;connect timeout=6000;applicationintent=ReadWrite;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /> 
    </connectionStrings> 
    <system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" switchValue="Information, ActivityTracing"> 
     <listeners> 
      <add name="log" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces.scvlog"></add> 
     </listeners> 
     </source>  
    </sources> 
    <trace autoflush="true"></trace> 
    </system.diagnostics> 

合同:

[OperationContract] 
[WebGet(UriTemplate = "/GetDeliveryInstructions?authenticationToken={AUTHENTICATIONTOKEN}&countryCode={COUNTRYCODE}&beginDate={BEGINDATE}&endDate={ENDDATE}", ResponseFormat = WebMessageFormat.Xml)] 
      List<DeliveryInstruction> GetDeliveryInstructions(string authenticationToken, string countryCode, string beginDate, string endDate); 

服務方法:

public List<DeliveryInstruction> GetDeliveryInstructions(string authenticationToken, string countryCode, string beginDate, string endDate) 
     { 
      try 
      { 
       if (AuthenticationTokenValidator.IsValidToken(authenticationToken)) 
        return DeliveryInstructionAdministrator.GetList(countryCode, beginDate, endDate).ToList(); 
       else 
        throw new InvalidOperationException("Your token is invalid or expired.");      
      } 
      catch (FaultException<TimeoutException>) 
      { 
       return DeliveryInstructionAdministrator.GetList(countryCode, beginDate, endDate).ToList(); 
      } 
      catch (FaultException faultException) 
      { 
       WebServiceExceptionLog logEntry = new WebServiceExceptionLog(faultException, "Logistics.Wcf", "GetDeliveryIntructions", faultException.GetType().ToString(), authenticationToken); 
       ExceptionLogger.LogException(logEntry); 
       return null; 
      } 
      catch (CommunicationException communcationException) 
      { 
       WebServiceExceptionLog logEntry = new WebServiceExceptionLog(communcationException, "Logistics.Wcf", "GetDeliveryIntructions", communcationException.GetType().ToString(), authenticationToken); 
       ExceptionLogger.LogException(logEntry); 
       return null; 
      } 
     } 

* UPDATE * 問題是與實體框架。我正在使用實體框架來檢索POCO實體。仍然不知道如何解決它。

+1

我不請參閱wcf trace偵聽器設置中的錯誤。這可能會爲你帶來更多的光芒。 –

+2

這可能是一個愚蠢的問題;但是您是否檢查過EventLogs以查看發生了什麼?您有時會在那裏看到您沒有在實際應用程序中獲得的例外信息。此外,請檢查服務器託管時是否可以通過HTTP訪問服務,這將排除這是純粹的IIS還是服務器問題,而更多的是通過HTTPS端口443訪問的問題。也;請仔細檢查您是否還有服務器上的服務的HTTPS綁定。 – Kaiser12

回答

0

您應該在您的服務器上啓用wcf日誌記錄。不過,我已經看到了這個錯誤時,沒有在web.config中正確設置了maxRequestLength和收到的消息,其中大:

<system.web> 
    <httpRuntime maxRequestLength="10000" /> 
</system.web> 

啓用跟蹤:

<configuration> 
<system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" 
       switchValue="Information, ActivityTracing" 
       propagateActivity="true"> 
     <listeners> 
      <add name="traceListener" 
       type="System.Diagnostics.XmlWriterTraceListener" 
       initializeData= "c:\log\Traces.svclog" /> 
     </listeners> 
    </source> 
    </sources> 
</system.diagnostics> 
</configuration> 

Tracing WCF

+0

我確實在服務器上啓用了跟蹤。 – broguyman

+0

什麼是日誌? – Peter