I’m trying to get a simple Spring.NET webservice working with MVC3 but although there are no errors, and I can see from the logs that Spring is deploying it, I can’t htt the correct URL for my web service at all.
I think I’ve followed the example (that comes with Spring.NET) correctly. Mine differs in that I’m not doing any AOP weaving on my service. As far as I can tell, it should work…. but doesn’t.
Here’s my service class (very basic)
public interface IHelloService
{
string SayHello();
}
public class HelloService : IHelloService
{
public String SayHello()
{
return "Hello";
}
}
And here’s my config
<!-- Web services -->
<object id="HelloService" type="Munch.Service.Web.HelloService, Munch.Service"/>
<!-- Exports contact service (weaved or not) as a web 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>
I would expect to be able to access my web service at something like http://localhost:8080/Munch/HelloWebService.asmx but no joy with any of the variations I have tried. Is there a way to find out what web services have been deployed (some debug page perhaps)?
The example that comes with Spring does actually work(!) so I know it’s possible to get a working Spring WS on my machine, I just can’t see where I’ve gone wrong.
I was able to use to publish your
HelloServicein the spring.netSpring.Mvc3QuickStartthat ships with spring.net 1.3.2.These were the things I had to do to get it to work:
routes.IgnoreRouteSpring.Web.Services.WebServiceHandlerFactoryfromSpring.Web, as bbaia had commented on your questionI suspect you’ve forgotten to add all asmx resources to
routes.IgnoreRoute.Step-by-step
Start with the Spring.Mvc3QuickStart example application that ships with Spring.Net 1.3.2.
Reference the project that contains the
HelloServiceclass from your question.Add a file
~/Config/services.xmlto the project, containing your service configuration:In Global.asax, add
to
RegisterRoutes. This will tell the asp.net mvc handler to leave requests to asmx resources alone.In web.config, add the following http handler:
In web.config, add your service configuration to the spring context:
When you run the application from Visual Studio, you should be able to view the service at http://localhost:12345/HelloWebService.asmx (replace 12345 with you dev port).
Notes
I’m unfamiliar with asp.net-mvc, so there might be better ways to configure it than I’ve suggested.