在 IIS6.0 Win2K3 环境中的 WCF Rest 服务中获取 MethodAccessException(在服务器的事件日志中)和 HTTP 错误 401 Unauthorized(在客户端)

发布于 2024-10-07 22:49:50 字数 643 浏览 0 评论 0原文

我编写了一个基于 WCF REST 的服务,该服务使用 webHttpBinding 并使用 JSON 来发布数据。该服务在我们所有的内部环境中都运行良好。但在我们的环境中,它是生产环境的精确复制品。它不起作用。如果我在 Firebug 中检查,我会看到“HTTP 错误 401 未经授权”,并且在服务器中我会在事件日志中看到以下内容。

System.MethodAccessException

System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous

MethodAccessException: System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(System.Web.HttpApplication, Boolean) 在 System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context)

我还没有粘贴整个事件日志。但是,以上是它的关键部分。

我无法弄清楚发生了什么,我们正在使用自定义 httpmodule 进行身份验证。

需要紧急帮助,

提前致谢

I wrote a WCF REST based service that uses webHttpBinding and uses JSON to post data.This service works fine in all of our internal environments. But in one of our environment which is exact replica of Production. It is not working. If I inspect in Firebug, I see "HTTP Error 401 Unauthorized" and in server I See following in the event log.

System.MethodAccessException

System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous

MethodAccessException: System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(System.Web.HttpApplication, Boolean) at System.ServiceModel.Activation.HttpHandler.ProcessRequest(HttpContext context)

I haven't pasted the whole event log. But,afore are the key parts of it.

I am not able to figure out what is happening, we are using custom httpmodule for authentication.

Need urgent help on this

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空名 2024-10-14 22:49:51

来自 MSDN,当您尝试从不允许的地方调用私有/受保护的方法时,会发生 MethodAccessException。这是在反射期间抛出的,这很可能是 WCF 在幕后所做的事情。

我敢打赌,您的服务方法之一被标记为私有或受保护。

这适用于您的本地环境,因为它处于完全信任状态。您的生产环境很可能在中等信任度下运行。 (在中等信任下,您不能绕过可访问性修饰符。)

——Tatham

From MSDN, a MethodAccessException occurs when you try to call a private/protected method from somewhere that you aren't allowed. This is thrown during reflection, which is more than likely what WCF is doing under the covers.

My bet is that one of your service methods is marked as private or protected.

This would work in your local environment because it's under Full Trust. Your production environment is most likely running in Medium Trust. (Under Medium Trust, you aren't allowed to bypass the accessibility modifiers.)

-- Tatham

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文