c# - IIS 的 WCF 服务宿主,spring.net 范围 ="request"

标签 c# wcf iis spring.net

我想在我的 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>

而且因为我是window 7,framework 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"/>

正如评论中所建议的那样,它不起作用。

最佳答案

我在spring源代码中查看了一个机器人,如果我添加

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

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

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

关于c# - IIS 的 WCF 服务宿主,spring.net 范围 ="request",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7832664/

相关文章:

c# - 有没有办法将功能与用户控件关联起来

c# - EDMX 生成 Nullable bool 而不是 bool

wcf - 在自定义 IIS 帐户下运行的远程调试 WCF 服务

wcf - WCF 4.0:WebMessageFormat.Json无法使用WCF REST模板

c# - 如何在 WinXP 中使用 IIS 5.1 发送邮件?

c# - 需要一些帮助来破译来自 .NET JITted 代码的一行汇编代码

c# - 保存 ArrayList 以供下次程序执行时使用

javascript - 关于将大字符串发布到 Web 服务的建议

php - 如何在 Windows/IIS 服务器上获取当前页面的完整 URL?

powershell - 为什么 Get-ItemProperty 不区分大小写,而 Set-ItemProperty 区分大小写?