我一直在与 EF 一起使用 WCF,并且遇到了发送集合的问题。
我正在使用由 2 个解决方案组成的游乐场,这只是我需要通过线路进行交流的最低限度。在两者之间发送字符串可以正常工作,通过客户端在数据库中添加记录也可以正常工作。但是,我的服务公开了以下合同:
[OperationContract]
IEnumerable<Company> GetAllCompanies();
在我的服务中实施,例如:
public IEnumerable<Company> GetAllCompanies()
{
using (var ctx = new InleerAppContext())
{
return ctx.Company.ToList();
}
}
没有什么不寻常的,因为发送对象似乎工作正常,我希望这也能工作。但是,当从我的客户调用 GetAllCompanies() 时:
var result2 = service.GetAllCompanies();
foreach (Company c in result2)
{
Console.WriteLine(c.Name);
}
一个 CommunicationException 被抛出:
接收对http://localhost:8080/的 HTTP 响应时出错 。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于服务器中止了 HTTP 请求上下文(可能是由于服务关闭)。有关更多详细信息,请参阅服务器日志。
更多信息:
在 System.Net.HttpWebRequest.GetResponse()
在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度超时)
我已经通过使用自定义绑定配置(双方都是 basicHttpBinding)在客户端和服务器上将超时更改为 30 分钟:
<bindings>
<basicHttpBinding>
<binding name="longTimeoutBasicHttpBinding"
receiveTimeout="00:30:00"
sendTimeout="00:30:00">
</binding>
</basicHttpBinding>
</bindings>
我在这里想念什么?