悬赏园豆:100
[已解决问题]
解决于 2008-04-27 21:12
<SPAN>
<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. ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.</P>
<P> at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)</P>
<P> </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>