gpt4 book ai didi

WCF HTTP 504 错误

转载 作者:可可西里 更新时间:2023-11-01 16:28:55 25 4
gpt4 key购买 nike

我有以下问题。我正在使用 Entity Framework 连接到 SQL Azure 并且可以正常工作(我在测试项目中对其进行了测试)。

但是当我尝试通过 WCF RESTful 服务获取它时,它会抛出错误 504。

我的运营契约(Contract):

[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "/Artikli", ResponseFormat = WebMessageFormat.Json)]
IEnumerable<Artikal> GetArtikli();
}

[ServiceContract] 的实现:

public class Service : IService
{
public IEnumerable<Artikal> GetArtikli()
{
using (var context = new CijenolomciEntities())
{
var result = context.Artikals.ToList();
result.ForEach(a => context.Detach(a));
return result;
}

}
}

整个事情都托管在本地 IIS 上。我使用 Fiddler,当我尝试到达时它会说什么

http://localhost:17916/Service.svc/Artikli 

[Fiddler] ReadResponse() 失败:服务器未返回对此请求的响应。

WCF App.Config 看起来像:

    <?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="CijenolomciEntities" connectionString="My_Connection_String" providerName="System.Data.EntityClient" />
</connectionStrings>

<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>

<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="webHttpBinding" />
</protocolMapping>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

</configuration>

编辑:当我尝试通过浏览器访问 URL 时,我得到以下信息:

Request Error

The server encountered an error processing the request. See server logs for more details.

最佳答案

尝试启用Tracing并查看您的请求是否超出了您收到超时错误的默认值。

检查跟踪日志以了解失败原因的详细错误,然后适本地执行所需的步骤以增加超时值或默认大小限制

关于WCF HTTP 504 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9804487/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com