【发布时间】:2014-11-17 16:38:08
【问题描述】:
我在 WCF 服务中使用 LINQ。我试图在网格中列出我所有的电影,但我的查询不起作用。 大家知道为什么吗?
这是查询:
public List<MovieInfo> GetAllMovies()
{
var queryResult = (from x in db.MovieInfos
select x);
return queryResult.ToList();
}
这是网络配置:
<configuration>
<connectionStrings>
<add
name="dmaa0913Sem3_1ConnectionString"
connectionString="Data Source=dbname;Initial Catalog=dataname;Persist Security Info=True;User ID=username;Password=password"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 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="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
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>
</configuration>
这是我得到的错误:
调用服务失败。可能原因:服务离线 或无法访问;客户端配置不匹配 代理;现有代理无效。请参阅堆栈跟踪 更多详情。您可以尝试通过启动新代理来恢复,恢复 到默认配置,或者刷新服务。
服务在线,因为我使用的是WCF测试客户端。
【问题讨论】:
-
看看 wcf 测试客户端生成的配置,并与客户端应用程序中的配置进行比较。
-
如果您无法成功调用 WCF 服务,我看不出这是一个 LINQ 问题或 LINQ 代码 sn-p 如何提供帮助。我错过了什么?您是否浏览过错误消息中建议的可能问题和解决方案?
-
我可以成功,插入,更新和删除。我只是不能从数据库中“提取”对象,对不起,如果不是正确的词。我还有另一个名为 Users 的服务,在那里我有完全相同的查询。但是我从 db.Users 中选择而不是 db.movieinfos 并且它有效。是的,我尝试过查看错误消息,但不明白为什么会出错。
-
您如何托管服务? IIS、Windows 服务、控制台应用程序等?你如何调用服务?最可能的罪魁祸首是 a) 客户端配置错误,b) 服务未运行或 c) 服务配置存在问题。发布您的服务和客户端配置以及如何从客户端调用服务的示例将帮助我们帮助您。就目前而言,您的帖子中没有足够的信息来为您提供比“试试这个、那个和这个”更多的信息。
-
我正在使用 WCF 测试客户端来调用查询。我只是使用那里的调用按钮来测试它。我用 IIS 托管它