PDA

View Full Version : Adding WebMethod references directly to a ServicedComponent


Alistair
06-11-2005, 01:07 PM
Hi

This isn't really tied to Spring directly, but I am interested in anyone's opinion about how I am going about defining web services. I've looked at the web services exporter code in Spring and am interested but probably won't seriously considered it until the 0.7 release is done.

In our current application architecture, web service calls are delegated to COM+ serviced components for implementation (which in turn are delegated to POCOs through Spring). This is because we want COM+ declarative transaction management across all our service implementations.

I have found that I can add the [WebMethod] attributes directly to the ServicedComponent along side the [Transaction...] attributes and then simply change the .ASMX file to list the ServicedComponent as the Class attribute (rather than the default code behind class). The ServicedComponent is activated as a Library application and everything works great. The ServicedComponent implements a "service" interface which I intend on using in the client with the Spring WebServiceHandlerFactory to be able to access the proxy via an interface.

This approach saves having a code behind file that has to explicitly delegate to ServicedComponent.

I've not been able to find any references on the web to others doing this. Does anyone see any problem with this approach?

Thanks
Alistair

Aleks Seovic
06-11-2005, 03:07 PM
I don't see a problem with the approach, and it does save you from writing a bunch of dumb delegates.

I'd probably use Spring WebServiceHandlerFactory and *.webservice object definitions to point to implementation classes. That would allow you to keep all the mappings between service names and implementation classes in one config file, instead of having them scattered over many .asmx file that are for all practical purposes completely useless.

That functionality is safe to use even now, as it doesn't do any dynamic proxying or other "fancy" stuff that web service exporter does -- it simply allows you to define web service mappings within the Spring context. Keep in mind that you won't be able to inject anything into your service implementation this way (you have to use exporter for that), but it seems like you don't need to anyway, because your web service/serviced component implementation delegates to a normal Spring-managed object where you can inject any dependencies you need.

Client side proxy factory is fairly safe to use as well, even though it does generate dynamic proxy. I believe it's well worth using so you don't have to modify VS.Net generated proxies by hand and make them implement your interface.

I also wouldn't recommend using web service exporter in a production app, because that's one thing that might change quite a bit before the official release, but if you get a chance to experiment with it and provide feedback and suggestions we'd appreciate it very much.

Regards,

Aleks

Alistair
06-12-2005, 01:48 AM
Aleks, thanks for your advice. I will give the WebSeriveHandlerFactory a go - removal of .ASMX files will be nice.

I'm already planning on using the client side proxy factory... I can't believe that Visual Studio has such little support for interface based design (you can't even create an interface directly within the tool without creating a class and "fixing" it by hand!).

I will let you know if I have a chance to experiment with the web service exporter.

regards
Alistair