wpf如何调用RIAService

xiaogua 2010-08-23 05:04:58
请问WPF如何调用Silverlight已经建好的RIAService,直接调用或者有其他方式间接调用?为了少些重复的代码.
...全文
360 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaogua 2010-09-05
  • 打赏
  • 举报
回复
Microsoft.ServiceModel.DomainService.Hosting 从mircrosoft帮助 文档里拷贝出来的东西居然不对,Microsoft.ServiceModel.DomainServices.Hosting,这样才对。谢谢大家
xiaogua 2010-08-26
  • 打赏
  • 举报
回复
需要安装 WCF RIA SERVICE toolkit,这个里面包含了SOAP和Json的EndPointFactroy。
具体步骤如
http://blog.csdn.net/dujingjing1230/archive/2010/04/27/5532085.aspx
中所描述,但是在本机失踪是编译通过但无法运行.
异常信息如下:
位于 System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error)
位于 System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error)
位于 System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
位于 System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.<Load>b__17(Object )

在页面访问直接对应的SVC,直接显示
Could not load file or assembly 'Microsoft.ServiceModel.DomainService.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. 系统找不到指定的文件。

我确认了在BIN目录下的确已经有这个文件,为何这里又Load不了?
本人所有用环境 VS2010,SL4 均为正式版, WCF RIA Service toolkit是4月份的版本.

是否有人有遇到同样问题,如何 解决?
Sunpire 2010-08-26
  • 打赏
  • 举报
回复
嗯,这个错误是说元数据的终结点没有被公布出来,所以无法在“添加服务引用”时自动生成代码,
但是反过来,如果代码已经生成了,那么是可以调用服务的。

貌似 WCF RIA Services 中不知道如何配置服务,包括 Endpoint、超时时间 等等。
xiaogua 2010-08-24
  • 打赏
  • 举报
回复
错误如:
Metadata contains a reference that cannot be resolved: 'http://localhost:3466/Services/SLwithRIAService-Web-DomainService1.svc?wsdl'.
The document format is not recognized (the content type is 'text/html; charset=UTF-8').
Metadata contains a reference that cannot be resolved: 'http://localhost:3466/SLwithRIAService-Web-DomainService1.svc'.
There was no endpoint listening at http://localhost:3466/SLwithRIAService-Web-DomainService1.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
xiaogua 2010-08-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sunpire 的回复:]
假设 Silverlight + RIA 的解决方案中,Silverlight 项目为 BusinessApplicationXXX ,
Web项目(DomainService项目)为BusinessApplicationXXX.Web,
那么在编译后,在 BusinessApplicationXXX 项目中有一个没有包含在项目内的目录
Generated_Code ,里面有一个 Busin……
[/Quote]


这个的确在Generated_Code生成的文件里面有
BusinessApplicationXXX-Web-AuthenticationService.svc
字样的创建,但是机制是不同的,在浏览器也可以直接访问(如:http://localhost:XXXX/BusinessApplicationXXX-Web-AuthenticationService.svc

但是WPF在引用的时候会提示找不到,不知道为什么找不到,用浏览器确实可以访问的?如何解决这个问题?
pavee 2010-08-24
  • 打赏
  • 举报
回复
估计你调用RIAService是指DomainService。在Silverlight的DomainService里,用户可以创建Business logic, 这是微软在介绍WCF RIA Services中说的。但我觉得还是尽量不用这种方式,Model和MVVM projects 建立在Client Side或许更好。建议读关于Silverlight结构的文章:
http://coolthingoftheday.blogspot.com/2010/04/silverlight-4-ria-services-mef-and-mvvm.html
dui_cky 2010-08-24
  • 打赏
  • 举报
回复

路人甲,学习。。。
Sunpire 2010-08-23
  • 打赏
  • 举报
回复
假设 Silverlight + RIA 的解决方案中,Silverlight 项目为 BusinessApplicationXXX ,
Web项目(DomainService项目)为BusinessApplicationXXX.Web,
那么在编译后,在 BusinessApplicationXXX 项目中有一个没有包含在项目内的目录
Generated_Code ,里面有一个 BusinessApplicationXXX.Web.g.cs 文件,

这个文件中就含有 DomainService 的实际Endpoint的Uri,如

public AuthenticationContext() :
this(new WebDomainClient<IAuthenticationServiceContract>(new Uri("BusinessApplicationXXX-Web-AuthenticationService.svc", UriKind.Relative)))
{
}


http://localhost:XXXX/BusinessApplicationXXX-Web-AuthenticationService.svc
就是RIA服务的Endpoint的Uri了。

部署在IIS上也应是一样的吧,楼主可以试一下。WPF调用还不存在 Silverlight跨域 问题。
xiaogua 2010-08-23
  • 打赏
  • 举报
回复
注:是在VS2010下面。不是2008版本

8,735

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧