首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF HTTP 504错误

WCF HTTP 504错误
EN

Stack Overflow用户
提问于 2012-03-21 12:19:57
回答 3查看 6.3K关注 0票数 2

我有以下问题。我使用实体框架连接到SQL,这是可行的(我在一个测试项目中测试了它)。

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

我的经营合同:

代码语言:javascript
复制
[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebGet(UriTemplate = "/Artikli", ResponseFormat = WebMessageFormat.Json)]
    IEnumerable<Artikal> GetArtikli();
}

[ServiceContract]的实现:

代码语言:javascript
复制
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,当我试图接触它时,它会说什么

代码语言:javascript
复制
http://localhost:17916/Service.svc/Artikli 

[Fiddler] ReadResponse() failed: The server did not return a response for this request.

WCF App.Config看起来是这样的:

代码语言:javascript
复制
    <?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时,我得到以下内容:

代码语言:javascript
复制
Request Error

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

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-03-21 13:00:21

尝试启用跟踪,并查看请求是否超过了导致超时错误的默认值。

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

票数 4
EN

Stack Overflow用户

发布于 2012-03-21 12:32:00

如果您的网络环境设置为使所有HTTP流量都通过代理服务器,那么IIS应用程序池所运行的帐户很可能不允许发送HTTP流量。作为测试,将应用程序池帐户更改为您的登录帐户,并查看WCF服务是否成功连接。504消息通常是代理或网络问题。

票数 0
EN

Stack Overflow用户

发布于 2012-03-21 12:53:31

我不认为这是网络错误。这个问题已经解决了。可能您收到的504不是来自IIS,而是来自Fiddler。阅读这篇文章。也许你必须增加maxItemsInObjectGraph

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9804487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档