首页 新闻 会员 周边

SharePoint自定义WebService代理类使用问题

0
悬赏园豆:100 [已解决问题] 解决于 2008-04-27 21:12
<SPAN>&nbsp; <P align=left><FONT style="BACKGROUND-COLOR: #fffbf0" face=Arial size=2>我自定义了一个WebService用于操作MOSS文档库。测试完成后使用了强命名并将相关程序集注册到GAC中。WebService文件名为:Service.asmx。将此文件部署到C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\ 目录下。该目录有MOSS提供的WebService。</FONT></P> <P align=left><FONT style="BACKGROUND-COLOR: #fffbf0">客户端Winform使用生成的代理类连接server。抛出SecurityException。</FONT></P> <P>System.Web.Services.Protocols.SoapException: Server was unable to process request. ---&gt; System.Security.SecurityException: That assembly does not allow partially trusted callers.</P> <P>&nbsp;&nbsp; at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)</P> <P>&nbsp;</P> <P align=left>查找了MSDN文档:<A title=http://msdn2.microsoft.com/zh-cn/library/970x52db(VS.80).aspx href="http://msdn2.microsoft.com/zh-cn/library/970x52db(VS.80).aspx"><FONT color=#800080>http://msdn2.microsoft.com/zh-cn/library/970x52db(VS.80).aspx</FONT></A>。按照说明把Web服务类声明为</P><PRE class=libCScode id=ctl00_rs1_mainContentContainer_ctl08CSharp>[PermissionSet(SecurityAction.InheritanceDemand, Name=<SPAN style="COLOR: maroon"><SPAN style="COLOR: maroon">"FullTrust"</SPAN></SPAN>)] 重新部署后。依然无法从客户端访问。</PRE> <DIV align=left><PRE class=libCScode>问题:</PRE><PRE class=libCScode>1、如何将客户端的访问权限设置为full trusted callers,可以正常使用服务器资源?</PRE><PRE class=libCScode>2、为什么我使用了强命名,把asmx部署到<FONT style="BACKGROUND-COLOR: #fffbf0">C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\ 目录下。通过<A title=http://localhost/_vti_bin/Service.asmx href="http://localhost/_vti_bin/Service.asmx"><FONT color=#0000ff>http://localhost/_vti_bin/Service.asmx</FONT></A>可以访问,通过代理类客户端连HelloWorld方法都无法访问;</FONT></PRE><PRE class=libCScode><FONT style="BACKGROUND-COLOR: #fffbf0">没有使用强命名就不能访问<A title=http://localhost/_vti_bin/Service.asmx href="http://localhost/_vti_bin/Service.asmx"><FONT color=#0000ff>http://localhost/_vti_bin/Service.asmx</FONT></A>。MOSS提示Error:The file you are attempting to save or retrieve has been blocked from this Web site by the server administrators. 我不使用强命名,则可以通过代理类访问helloworld的方法。需要调用MOSS 对象的方法都因缺少权限而无法访问。这是为什么?如何解决?</FONT></PRE><PRE class=libCScode><FONT style="BACKGROUND-COLOR: #fffbf0">finalService.Credentials = CredentialCache.DefaultCredentials;<BR></FONT></PRE><PRE class=libCScode><FONT style="BACKGROUND-COLOR: #fffbf0">NetworkCredential nc = new NetworkCredential();<BR>nc.UserName = "Administrator";<BR>nc.Password = "Password";<BR>nc.Domain = "Domain";<BR>finalService.Credentials = nc;</FONT></PRE><PRE class=libCScode><FONT style="BACKGROUND-COLOR: #fffbf0">上面两种方法我都用过,都无法正常使用代理类。项目要求比较紧。哪位知道,请联系<A title=mailto:jerry_chen_cn@hotmail.com href="mailto:jerry_chen_cn@hotmail.com"><FONT color=#0000ff>jerry_chen_cn@hotmail.com</FONT></A> 。 谢谢大家!</FONT></PRE></DIV></SPAN>
jerry.chen的主页 jerry.chen | 初学一级 | 园豆:100
提问于:2008-04-25 21:53
< >
分享
最佳答案
0
楼主,为何不将你的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
刚刚 | 老鸟四级 |园豆:3151 | 2008-04-27 19:59
其他回答(1)
0
这个应该不是权限 问题 之前看过另一个应用,WCF, 这个 叫做 部分信任 调用 对HTTP请求 部分信任 ,不过我也么没有弄明白, MSDN(杂志)的上的文章,有中文的(2008年4月的) 另一个,SharePoint 会从新映射 IIS 请求处理。你那个访问,还没有到你那,已经被ShirePoint 拦截了~
G yc {Son of VB.NET} | 园豆:2006 (老鸟四级) | 2008-04-26 22:06
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册