连接到第三方 Web 服务的报告服务和自定义程序集
我有以下问题。我正在使用 Reporting Services 2005 创建一些报告。我从自定义程序集中调用方法,当我的方法如下时,它工作正常:
public static string TestMethod() {
return "test"; }
但是,当返回“test”时;被调用第三方 Web 服务的代码替换,我的 RS 报告中没有返回任何内容。我什至无法将异常记录到事件日志(可能是出于安全原因)。 I 类由以下语句修饰:
[System.Web.AspNetHostingPermission(SecurityAction.Assert, Level = System.Web.AspNetHostingPermissionLevel.Unrestricted)]
另外,为了调用 Web 服务,我在自定义程序集中添加了以下内容:
string serviceUri = "http://externallink/Default.asmx";
WebPermission p = new WebPermission(NetworkAccess.Accept, serviceUri);
p.Assert();
这也没有帮助。我的自定义程序集中抛出的错误如下:
请求类型许可 'System.Net.WebPermission,系统, 版本=2.0.0.0,文化=中立, 公钥令牌=b77a5c561934e089' 失败
有人可以帮助我吗?
编辑1: 我发现报告服务使用名为:RosettaSrv 的自定义信任级别。自定义策略在 rssrvpolicy.config 中设置。当我将信任级别更改为“完全”时,一切正常。但是我不想指定完全信任,只是指定访问自定义 Web 服务的可能性,我该怎么做?
I have the following problem. I am using Reporting Services 2005 to create some report. I call method from my custom assembly and it works fine when my method is as follows:
public static string TestMethod() {
return "test"; }
However, when return "test"; is replaced by the code that calls third party web service, there is nothing returned to my RS report. I can't even log my exception to EventLog (probably because of security reasons).
I class is decorated by the following statement:
[System.Web.AspNetHostingPermission(SecurityAction.Assert, Level = System.Web.AspNetHostingPermissionLevel.Unrestricted)]
additionally, for the purpose of calling web service I've added the following in my custom assembly:
string serviceUri = "http://externallink/Default.asmx";
WebPermission p = new WebPermission(NetworkAccess.Accept, serviceUri);
p.Assert();
This does not help either. The error that is thrown in my custom assembly is as follows:
Request for the permission of type
'System.Net.WebPermission, System,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'
failed
Can someone can please help me?
EDIT1:
I figured out that reporting services uses custom trust level called: RosettaSrv. Custom policy is set in rssrvpolicy.config. When I changed trust level to Full, everything works fine. However I don't want to specify full trust, just possibility to access custom web services, how can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在 RS 的 CAS 策略配置文件(如您提到的)中创建特定的 CodeGroup 部分,这告诉它为您的程序集授予该权限。
请按照此 MSDN 文章中的步骤了解详细信息:http://support.microsoft.com/kb/842419
you have to create your specific CodeGroup section in the CAS policy config file (as you mentioned) for RS, which tells it to grant that permission for your assembly.
Follow steps found in this MSDN article for details: http://support.microsoft.com/kb/842419