我自定义了一个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 。 谢谢大家!