【问题标题】:WCF service host by IIS, spring.net scope="request"IIS 的 WCF 服务主机,spring.net scope="request"
【发布时间】:2011-10-20 07:47:22
【问题描述】:

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

按照 cmets 的建议,它不起作用。

【问题讨论】:

  • 您似乎只为 *.aspx 资源添加了处理程序。
  • 好吧,我必须说我真的不知道我做了什么,到底什么是处理程序?我只是从 Spring 配置中复制这些行。如何为所有资源启用处理程序?通过设置路径 =“*”。我试试看
  • Spring.Web.Support.PageHandlerFactorySpring.Web.Pages 的工厂,所以我认为您不能将它用于您的 wcf 端点。恐怕现阶段我对 wcf 了解的太少,无法进一步提供帮助,抱歉。

标签: c# wcf iis spring.net


【解决方案1】:

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

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

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

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

【讨论】:

  • 不错的发现,+1。关于使用 spring.net 进行日志记录:this post 可能会有所帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-13
相关资源
最近更新 更多