我的一个WCF方法返回一个实体框架实体的数组,如下所示:
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;
}
}有没有人对这个问题有什么看法?
向您致敬,马克
发布于 2010-05-20 00:28:57
会不会是你今天比昨天选择了更多的条目?会不会是您的服务方法返回数据的时间比默认的60秒更长?或者,返回的实体的数据大小是否超过64K?
我会做两件事:
1)打开异常详细信息,这样您就可以在客户端获得详细的异常消息-希望它能为您指明正确的方向
2)打开WCF消息日志记录,查看线路上发生了什么
对于第1点,您需要启用serviceDebug行为:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="debug" name="YourWCFService"><diagnostics>
<messageLogging
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
logEntireMessage="true" logMalformedMessages="true"
maxMessagesToLog="2500" maxSizeOfMessageToLog="256000" />
</diagnostics> <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中启用跟踪的其他信息来源:
发布于 2010-05-20 00:05:35
最有可能的是你有连接问题。我的意思是,您没有访问您试图访问的资源的权限。有没有防火墙之类的。为了确保这一点,请尝试从客户机远程登录服务器。
https://stackoverflow.com/questions/2867266
复制相似问题