来自 Web 服务项目的 RIA 身份验证 [英] RIA Authentication from a Web Services project

查看:19
本文介绍了来自 Web 服务项目的 RIA 身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 RIA 服务的 Silverlight 应用程序.我想重用 RIA 服务组件并从另一个 Web 服务调用它.Web 服务和 RIA 服务组件将位于同一台服务器上.

I have a silverlight app using RIA services. I want to reuse the RIA services component and call it from another web service. The web service and the RIA services component will be on the same server.

我已经走得很远了,我的网络服务项目有一个对 RIA 服务项目的服务参考",这一切都很好.但是当我调用 RIA 服务方法之一时,我得到了异常,

I have got quite far along, my web service project has a 'service reference' to the RIA services project which is all good. But when I call one of the RIA services methods I get the exception,

{DDB20766-F78A-42c7-B777-5ECF0AD9E4F3}Access to operation 'GetValidId' was denied.
at System.ServiceModel.DomainServices.Server.DomainService.ValidateMethodPermissions(DomainOperationEntry domainOperationEntry, Object entity)

RIA 服务域类具有 [RequiresAuthentication] 属性.我想了解如何指定这些凭据并进行身份验证?

The RIA services domain class has the attribute [RequiresAuthentication]. I am trying to understand how I can specify those credentials and authenticate?

就像测试一样,我注释掉了 [RequiresAuthentication] 属性,一切正常,没有任何问题.

Just as a test I commented out the attribute [RequiresAuthentication] and everything worked without any problems.

推荐答案

查看此链接:

http://www.ben-morris.com/using-the-wcf-authentication-service-without-cookies

基本上,您必须首先成功对您的服务器进行身份验证,然后让服务器向您发送一个身份验证 cookie,您可以通过编程方式将其添加到对 WCF RIA 方法的后续请求中,并打开 [RequiresAuthentication].

Basically, you have to first successfully authenticate against your server, and have the server send back to you an authentication cookie that you can programatically add to subsequent requests to WCF RIA methods with [RequiresAuthentication] turned on.

注意,要使其工作,在您的客户端程序中,当设置 WCF 绑定以调用您的服务器 WCF RIA 方法时,请确保 allowCookies="false";这将允许来自上述链接的代码实际上能够在标题中手动设置 cookie.

Note, to get this to work, in your client program, when setting up WCF bindings to call your server WCF RIA methods, ensure allowCookies="false"; this will allow the code from the above link to actually be able to manually set the cookies in the header.

这篇关于来自 Web 服务项目的 RIA 身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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