[已解决问题] SharePoint自定义WebService代理类使用问题
提问时间: 2008-04-25 21:53
悬赏分:100 浏览:244 次
 

我自定义了一个WebService用于操作MOSS文档库。测试完成后使用了强命名并将相关程序集注册到GAC中。WebService文件名为:Service.asmx。将此文件部署到C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\ 目录下。该目录有MOSS提供的WebService。

客户端Winform使用生成的代理类连接server。抛出SecurityException。

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.

   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)

 

查找了MSDN文档:http://msdn2.microsoft.com/zh-cn/library/970x52db(VS.80).aspx。按照说明把Web服务类声明为

[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust")]
重新部署后。依然无法从客户端访问。
问题:
1、如何将客户端的访问权限设置为full trusted callers,可以正常使用服务器资源?
2、为什么我使用了强命名,把asmx部署到C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\ 目录下。通过http://localhost/_vti_bin/Service.asmx可以访问,通过代理类客户端连HelloWorld方法都无法访问;
没有使用强命名就不能访问http://localhost/_vti_bin/Service.asmx。MOSS提示Error:The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators.  我不使用强命名,则可以通过代理类访问helloworld的方法。需要调用MOSS 对象的方法都因缺少权限而无法访问。这是为什么?如何解决?
finalService.Credentials = CredentialCache.DefaultCredentials;
NetworkCredential nc = new NetworkCredential();
nc.UserName = "Administrator";
nc.Password = "Password";
nc.Domain = "Domain";
finalService.Credentials = nc;
上面两种方法我都用过,都无法正常使用代理类。项目要求比较紧。哪位知道,请联系jerry_chen_cn@hotmail.com 。 谢谢大家!

提问者:jerry.chen - 初学一级
最佳答案
楼主,为何不将你的Web Services部署到IIS上,这样就能正常访问了,比如默认的IIS目录:C:\Inetpub\wwwroot下。而要放在C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\ 目录下,没明白这样做的目的。
如果你是出于对Web Services调用的安全性考虑,建议你开发的Web Services中加入Soap消息头,用做调用Web Services中的方法验证,这样不知道Soap消息头中的用户名和密码是不能调用方法的,不过你要在你的Web Services中的每个方法上加入Soap消息头验证判断。有关Soap消息头方面的内容请参阅我的博客中相关随笔,浏览地址:http://www.cnblogs.com/lijigang/archive/2006/11/02/547406.html

另外关于ASP.Net与Web Services的安全性,也可以参考我的博客中转载的随笔,浏览地址:http://www.cnblogs.com/lijigang/archive/2008/04/18/1159528.html
2008/4/27 19:59:33 回答者:刚刚


提问者对于答案的评价:谢谢你的回复。刚去blog上逛了逛,资料还挺多的。以后遇到问题请多多指教!我的联系方式:MSN:jerry_chen_cn(at)hotmail.com
其它回答(1)
这个应该不是权限 问题

之前看过另一个应用,WCF, 这个 叫做 部分信任 调用
对HTTP请求 部分信任 ,不过我也么没有弄明白, MSDN(杂志)的上的文章,有中文的(2008年4月的)

另一个,SharePoint 会从新映射 IIS 请求处理。你那个访问,还没有到你那,已经被ShirePoint 拦截了~ 
2个月前   回答者:G yc {Son of VB.NET} - 小虾三级
评论
2个月前   jerry.chen :
此问题我已经解决了。因为产品的特殊要求,所以必须要和MOSS自带的Web Service放在一起。其实就是一个自定义MOSS的sharepoint,只不过asmx文件、生成的disco文件以及wsdl要做一定的修改,可以参考MOSS自带的WebService。过段时间我会把子定义SharePoint2007的WebService方法贴上来。谢谢大家关注!
2个月前   刚刚 :
首先谢谢光临我的博客,万分感谢您的肯定。
非常期待你的大作。
最后祝你能圆满完成任务。
   您需要登录以后才能回答!
我的问题    我要提问


快到期问题

> 问题排行榜

有不合适内容,建议去除