使用WCF IQueryable的问题 [英] IQueryable problems using WCF
问题描述
我有它返回一个IQueryable,只是为了测试一个很简单的WCF服务的方法。也许我试图了解IQueryable的是专为当有东西是错误的。我清楚地打算使用此与NHibernate的IQueryable的供应商后。但首先,我遇到了某种序列化问题(至少我认为这可能是问题)使用WCF方法返回一个IQueryable时。它甚至没有工作的一个简单的字符串。
I have a quite simple WCF service method which returns an IQueryable, just for testing. Perhaps I got something wrong when trying to understand what IQueryable is designed for. I clearly plan to use this with the IQueryable provider of NHibernate later. But first I ran into some sort of serialization problems (at least I think it might be the problem) whenever using a WCF method returning an IQueryable. It doesn't even work for a simple string.
下面是我的code:
public IQueryable<string> GetEquipmentConfigurations()
{
var returnValue = new List<string>();
returnValue.Add("test");
return returnValue.AsQueryable();
}
这可能没有多大意义,它只是用于测试我是否真的得到这些IQueryables在使用WCF电线。每当我打电话使用客户端一样了SoapUI我得到一个插座异常和连接复位,只是一样的,如果我试图返回的东西没有被标记为DataContract此方法。但是,我在这里做的唯一事情是试图返回一些糟糕的字符串列表。有什么不好呢?
It might not have much sense, it's just for testing whether I really get those IQueryables over the wire using WCF. Whenever I call this method using a client like SoapUI I get a socket exception and a connection reset, just the same as if I was trying to return something that is not marked as DataContract. But the only thing I do here is trying to return some lousy string list. What's wrong with that?
我用basicHttpBinding的,这里是我的设置:
I use basicHTTPBinding, here are my settings:
<system.serviceModel>
<services>
<service name="EquipmentConfigurationService" behaviorConfiguration="DefaultBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/Krones.KBase/Services/EquipmentConfigurationService"/>
</baseAddresses>
</host>
<endpoint address=""
binding="basicHttpBinding"
contract="Krones.MES.KBase.Public.Service.EquipmentDefinition.IEquipmentConfigurationService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
在OperationContract的属性设置为接口:
The OperationContract attribute is set for the interface:
[OperationContract]
IQueryable<string> GetEquipmentConfigurations();
这一切运作良好时,只返回一个简单的字符串。无论如何,我想获取利润后使用LINQ的IQueryable的功能。
It all works well when just returning a simple string. Anyway I want to take profit from the IQueryable features using LINQ later.
任何人任何想法是怎么回事错在这里?
Anybody any idea what's going wrong here?
感谢和欢呼声中,
斯特凡
推荐答案
(过时) AFAIK这是不可能的开箱即用序列化的IQueryable&LT;>或Ex pression树(想想看 - 那岂不是前pression树/λ需要被序列化和功能重建的)
(Obsolete) AFAIK it isn't possible out of the box to serialize IQueryable<> or Expression Trees (think about it - it would mean that the expression tree / lambda would need to be serialized and the function rebuilt)
不过,这里有一个会,似乎还有一个办法 - 你可能想要看的项目,如本 HTTP://$c$c.msdn.microsoft.com/exprserialization
However, where there is a will, it seems there is a way - you might want to look at projects such as this http://code.msdn.microsoft.com/exprserialization
修改:请注意,时代已经变了 - 请参见WCF RIA服务按马克Gravell的帖子
Edit : Note that times have changed - See WCF RIA Services as per Marc Gravell's post.
祝你好运!
心连心
这篇关于使用WCF IQueryable的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!