在Silverlight业务应用程序中从域服务类调用WCF服务时出现问题 [英] Problem when calling WCF Service From Domain Service class in Silverlight Business Application

查看:67
本文介绍了在Silverlight业务应用程序中从域服务类调用WCF服务时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我有一个问题.我创建了新的Silverlight业务应用程序项目,并在Web项目部分添加了域服务类.现在,我想在域服务类中编写一个返回IQueryable<myclass>的方法,并从Silverlight项目客户端使用它.数据应从远程WCF服务(在IIS中托管)中获取,并且在那里也定义了"myWcfClass"(指定了SerializableAttribute和[Key]).

远程服务类的方法如下所示:

Hello to everybody.

I have one problem. I have created new Silverlight Business Application project and added Domain Service Class in web project part. Now I want to write one method in Domain Service Class that returns IQueryable<myclass> and use it from Silverlight projects Client side. The data should be taken from remote WCF Service (hosted in IIS) and "myWcfClass" is also defined there (with SerializableAttribute and [Key] specified).

The method of Remote Service Class looks like this one:

public IQueryable<mywcfclass> GetSomeList()
{
//this does not work because of GetmyWcfClass method returns myWcfClass[] type instead of List<mywcfclass>. is there any deal with it ???
       List<mywcfclass> = new Service1Client().GetmyWcfClass();
       . . . . . .
}</mywcfclass></mywcfclass></mywcfclass>


此方法中的代码无关紧要,当编译器看到myWcfClass(通过为WCF Web服务创建的Web服务参考)显示错误时:

实体"myBusinessApp.Web.RefRemoteWebService.myWcfClass"具有属性"ExtensionData",其类型不受支持.


我想让类似的东西起作用:


It does not matter what code is inside this method, when the compiler sees myWcfClass (through Web Service Reference I created for WCF Web Service) it shows the error:

Entity ''myBusinessApp.Web.RefRemoteWebService.myWcfClass'' has a property ''ExtensionData'' with an unsupported type.


I want to get something like this to work:

[Query]
public IQueryable<mywcfclass> GetSomeList()
{
     List<mywcfclass> lst = new Service1Client().GetmyWcfClass();
     return lst.AsQueryable();
}</mywcfclass></mywcfclass>



关于问候
非常感谢任何帮助.



With regards
Any help would be highly appreciated

推荐答案

可悲的是,我认为这样行不通. WCF将依赖于该方法的可序列化输出,而IQueryable则不会.恐怕您无法真正推迟跨序列化边界的执行.

您可以使用IEnumerable<> ;,但是在生成代理时,您需要选择公开方式(数组或通用列表).如果选择通用列表,则应该可以再次使用IQueryable方法.
Tragically, I don''t think that will work. WCF will rely in having a serializable output from the method and IQueryable won''t be. I''m afraid you can''t really defer execution across a serialization boundary.

You could use IEnumerable<>, but when you generate your proxy you''ll need to select how that will be exposed (Array or Generic List). If you pick generic list, you should be able to use the IQueryable methods again.


谢谢您的回答,也许我没有很好地声明我的问题.而且我的代码也没有完全显示在此站点上.我正在使用IQueryable< myclass>通用类,未显示.

Thank you for your answer, maybe I not declared my problem well. and my code also is not showed exactly by this site. I''m using IQueryable<myclass> generic class, that was not shown.

public IQueryable<myClass> GetSomeList()

此方法未在WCF服务中定义,但存在于域服务类中,WCF服务仅返回

this method is not defined in WCF Service, but exists in Domain Service Class, WCF Service returns just

List<myClass>


(myClass驻留在WCF中),但是在代理中,myClass看起来有所不同(添加了System.Runtime.Serialization.ExtensionDataObject类型的ExtensionData以获取更多信息),Silverlight无法将其理解为实体支持的类型,无法将其传输到Silverlight客户端

而且我也想告诉您类似的方法


(myClass resides in WCF), but in proxy myClass looks like different (there is ExtensionData of type System.Runtime.Serialization.ExtensionDataObject added for additional information) and Silverlight can''t understand it as supported type for entities, to transfer it to Silverlight client

And also I want to tell that similar method

public IQueryable<myLocalClass> GetSomeList()


在Domain Service Class中声明可以正常工作,并且可以很好地传输到Silverlight客户端(myLocalClass的声明方式与WCF Service中的myClass完全相同,但是它位于Domain Service Class的程序集中)


Declared in Domain Service Class works fine and is transfered to Silverlight Client side well (myLocalClass is declared absolutely in the same way myClass in WCF Service is, but it resides within Domain Service Class''s assembly)


好,非常感谢所有尝试帮助或更改我的帖子的人.我只是通过从myClass类型的生成的代理版本中删除ExtensionData属性来解决此问题
Ok, thank you very much everyone who tried to help or red my post. I solved this problem by just removing ExtensionData property from generated proxy version of my myClass type


这篇关于在Silverlight业务应用程序中从域服务类调用WCF服务时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆