我能用来发布你的 HelloService 在spring.net Spring.Mvc3QuickStart 与spring.net 1.3.2一起发布的。
HelloService
Spring.Mvc3QuickStart
这些是我必须做的事情才能让它发挥作用:
routes.IgnoreRoute
Spring.Web.Services.WebServiceHandlerFactory
Spring.Web
我怀疑你忘了添加所有asmx资源 routes.IgnoreRoute 。
一步步
从Spring.Net 1.3.2附带的Spring.Mvc3QuickStart示例应用程序开始。
引用包含的项目 HelloService 从你的问题上课。
添加文件 ~/Config/services.xml 到项目,包含您的服务配置:
~/Config/services.xml
<object id="HelloService" type="Munch.Service.Web.HelloService, Munch.Service"/> <object id="HelloWebService" type="Spring.Web.Services.WebServiceExporter, Spring.Web"> <property name="TargetName" value="HelloService"/> <property name="Namespace" value="http://Munch.Service.Web/HelloService"/> <property name="Description" value="Hello Web Services"/> <property name="TypeAttributes"> <list> <object type="System.Web.Script.Services.ScriptServiceAttribute, System.Web.Extensions"/> </list> </property> </object>
在Global.asax中,添加
routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
至 RegisterRoutes 。这将告诉asp.net mvc处理程序单独将请求留给asmx资源。
RegisterRoutes
在web.config中,添加以下http处理程序:
<system.web> <!-- ... --> <httpHandlers> <add verb="*" path="*.asmx" type="Spring.Web.Services.WebServiceHandlerFactory, Spring.Web" /> </httpHandlers> <!-- ... -->
在web.config中,将服务配置添加到spring上下文:
<spring> <context> <resource uri="file://~/Config/controllers.xml" /> <resource uri="file://~/Config/services.xml" /> </context> </spring>
从Visual Studio运行应用程序时,您应该能够在以下位置查看服务 HTTP://本地主机:12345 / HelloWebService.asmx (用你的dev端口替换12345)。
笔记
我对asp.net-mvc不熟悉,所以可能有比我建议更好的方法来配置它。