首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF中的CommunicationException

WCF中的CommunicationException
EN

Stack Overflow用户
提问于 2010-05-20 00:02:25
回答 2查看 1.2K关注 0票数 2

我的一个WCF方法返回一个实体框架实体的数组,如下所示:

代码语言:javascript
复制
    public BranchContactDetail[] GetClosestBranches(string postcode, int howManyBranches)
    {
        GeoLocation geoLocation = GetLocationFromPostcode(postcode);
        Location location = new Location(geoLocation.Latitude, geoLocation.Longitude);

        using (BranchDirectoryEntities entities = new BranchDirectoryEntities())
        {
            var branchesInOrder = entities.BranchContactDetails
                .Where(b => b.latitude.HasValue && b.longitude.HasValue )
                .OrderBy(b => location.DistanceFrom(b.latitude, b.longitude))
                .Take(howManyBranches)
                .ToArray();

            return branchesInOrder;
        }
    }

有没有人对这个问题有什么看法?

向您致敬,马克

EN

回答 2

Stack Overflow用户

发布于 2010-05-20 00:28:57

会不会是你今天比昨天选择了更多的条目?会不会是您的服务方法返回数据的时间比默认的60秒更长?或者,返回的实体的数据大小是否超过64K?

我会做两件事:

1)打开异常详细信息,这样您就可以在客户端获得详细的异常消息-希望它能为您指明正确的方向

2)打开WCF消息日志记录,查看线路上发生了什么

对于第1点,您需要启用serviceDebug行为:

代码语言:javascript
复制
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="debug">
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="debug" name="YourWCFService">

代码语言:javascript
复制
<diagnostics>
  <messageLogging
      logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
      logEntireMessage="true" logMalformedMessages="true"
      maxMessagesToLog="2500" maxSizeOfMessageToLog="256000" />
</diagnostics>

代码语言:javascript
复制
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
        <listeners>
          <add name="default"
               type="System.Diagnostics.XmlWriterTraceListener"
               initializeData="C:\yourlogfile.svclog" />
        </listeners>
      </source>
    </sources>
    <trace autoflush="true" />
  </system.diagnostics>

System.Diagnostics名称空间中有两个预定义的跟踪侦听器类型-使用任何现成的,或者创建自己的(例如,记录到数据库或类似的)。

查看有关如何在WCF中启用跟踪的其他信息来源:

  • Configuring Tracing
  • WCF Tracing and Message Logging
票数 1
EN

Stack Overflow用户

发布于 2010-05-20 00:05:35

最有可能的是你有连接问题。我的意思是,您没有访问您试图访问的资源的权限。有没有防火墙之类的。为了确保这一点,请尝试从客户机远程登录服务器。

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

https://stackoverflow.com/questions/2867266

复制
相关文章

相似问题

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