It's easy to export the AppFuse managers as a webservice to various clients using Spring remoting.

The HttpInvoker

If you only have Java clients, the easiest solution for exporting managers is using the HttpInvoker. As it uses Java serialization, you don't have to care about object mappings or conversions. Additionally, by using HTTP as a protocol, it's trivial to allow access to the services via a proxy. If you later on wish to change the protocol (e.g. to allow non-Java clients to access your services), Spring makes it easy to replace the remoting protocol by only changing one line in a config file.

Create a servlet

The managers will get exported using a servlet. Therefore you have to create two new files. The first one's purpose is to provide managers without access control. This is needed to allow clients to authenticate themselves. The second file contains managers, that get secured using Acegi, so only authenticated clients are able to use them.

src/main/webapp/WEB-INF/ws-servlet.xml src/main/webapp/WEB-INF/ws-secure-servlet.xml

Security settings

Now we have to modify the security settings, to secure our ws-secure-Servlet.

src/main/webapp/WEB-INF/security.xml
We have to add some additional beans to this configuration file: The next thing is to rename the bean called httpSessionContextIntegrationFilter in httpSessionContextIntegrationFilterWithASCTrue (it's not necessary by any means, but will help us to keep a better overview).

Finally we have to modify the bean filterChainProxy, so that the last two lines look like this: As you see, the services don't need all filters of the web-layer, plus we turned off session creation for the ws-subdiretory, as remoting clients don't need this.

Register the servlets

The servlets now have to be registered, so they'll be avilable to our clients. Because we therefore have to add some defintions into web.xml, we need to run mvn war:inplace (see AppFuse Quickstart Guide). You can safely remove all newly created files other than web.xml.

src/main/webapp/WEB-INF/web.xml