WCF服务由IIS托管,spring.net scope="request"

发布于 2024-12-11 03:02:11 字数 2115 浏览 2 评论 0 原文

我想在 xml 配置中启用 scope="request" 属性:

<object id="IDataAccess" type="Dal.DataAccess, Dal" scope="request">

我的 WCF 服务托管在 IIS 上,我使用 RouteTableServiceHostFactory 创建我的服务:

static void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.Add(new ServiceRoute("url", serviceHostFactory, typeof(MyService)));
}

我在 web.config 中添加了 WebContextHandler 以启用范围 requestsession如此处所述 http://www.springframework.net/doc-latest/reference/html/web .htm(第 22.3.1 节)

<sectionGroup name="spring">
  <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
</sectionGroup>

httpModules 事情:

 <system.web>
    <httpHandlers>
        <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
    </httpHandlers>
    <httpModules>
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
    </httpModules>
</system.web>

因为我使用的是 Windows 7,框架 Net 4.0,所以我还添加了:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
    </modules>
</system.webServer>

我做了所有这些。它不起作用,我仍然有:

Resource handler for the 'web' protocol is not defined.

当它调用时:

SpringContext = (IApplicationContext)ConfigurationManager.GetSection("spring/context");

我现在不知道该做什么,Spring.net 社区的人可以帮助我吗?看起来我并没有尝试做一些棘手或黑客的事情。在 IIS 中托管 WCF 服务是一种常见模式。

编辑

<add verb="*" path="*" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

按照评论中的建议进行了尝试,但它不起作用。

I would like to enable the scope="request" attribute in my xml configuration:

<object id="IDataAccess" type="Dal.DataAccess, Dal" scope="request">

My WCF service is hosted on IIS and I use RouteTable and ServiceHostFactory to create my service:

static void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.Add(new ServiceRoute("url", serviceHostFactory, typeof(MyService)));
}

I added the WebContextHandler in my web.config to enable the scope request and session as described here http://www.springframework.net/doc-latest/reference/html/web.htm (section 22.3.1)

<sectionGroup name="spring">
  <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
</sectionGroup>

And the httpModules thing:

 <system.web>
    <httpHandlers>
        <add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
    </httpHandlers>
    <httpModules>
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
    </httpModules>
</system.web>

And because I am on window 7, framework Net 4.0 I also added:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
    </modules>
</system.webServer>

I did all that. and it doesn't work, I still have:

Resource handler for the 'web' protocol is not defined.

when it calls:

SpringContext = (IApplicationContext)ConfigurationManager.GetSection("spring/context");

I don't what to do now, can someone from the Spring.net community help me. It doesn't look like I try to do something tricky or hacky. It is a common pattern to host a WCF service in IIS.

EDIT:

I tried with

<add verb="*" path="*" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

as suggested in comments and it doesn't work.

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

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

发布评论

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

评论(1

毁虫ゝ 2024-12-18 03:02:11

我查看了 spring 源代码中的机器人,如果我

ResourceHandlerRegistry.RegisterResourceHandler("web", typeof (WebResource));

在获取 ContextConfiguration 之前添加我的 Application_Start 方法,它就会完成这项工作。我不知道为什么。我认为这是当前 WebSupportModule 中的一个错误。

这很奇怪,因为这是在 WebSupportModule 的静态构造函数中调用的。我尝试为 Spring 启用日志记录,但日志文件已创建,但保持为空:/它可以帮助我更多地理解。

I looked a bot at the spring source code and if I add

ResourceHandlerRegistry.RegisterResourceHandler("web", typeof (WebResource));

in my Application_Start method, before getting the ContextConfiguration, it does the job. I have no idea why. I think it is a bug in the current WebSupportModule.

It is very strange because this is called in the static constructor of WebSupportModule. I tried to enable logging for Spring, but the log file is created, but stay empty :/ it could have helped me a bit more to understand.

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