我有一个 WCF 服务,它在我的本地计算机上托管时可以工作,但在服务器上使用 IIS 托管时不能工作。
抛出未处理的通信异常
. “接收到 {url} 的 HTTP 响应时发生错误。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于 HTTP 请求上下文被服务器中止(可能是由于服务关闭)。有关更多详细信息,请参阅服务器日志。”
内部异常是
“底层连接已关闭:接收时发生意外错误。”
我已经启用了跟踪,但由于我的错,我真的找不到任何我能看到的对我有帮助的东西。此外,我似乎有其他关于这个问题的线程,但似乎没有任何帮助。
服务器正在使用 https 我不禁认为这是问题所在。当我使用 http 在本地运行它时。一切正常。
这些调用正在检索大量数据,但我无能为力。
谁能帮我解决这个问题?
网络配置
<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="data source=hertz1105\devl;initial catalog=Logistics;user id=airclic2;password=air123_***;connect timeout=6000;applicationintent=ReadWrite;MultipleActiveResultSets=True;App=EntityFramework"" 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;
}
}
* 更新 * 问题出在实体框架上。我正在使用实体框架来检索 POCO 实体。仍然不确定如何解决它。