Hi all!

Consider the following use case for Synapse:

* Synapse is deployed as a Web application.
* The Synapse configuration has a service proxy that targets a service exposed by another Web application deployed on the same server.
* Both the proxy and the target use HTTP as transport protocol.
* The target Web application neither uses Axis, nor is it reasonable to change it in any way.

The obvious solution is to use HTTP to communicate with the target service. However using HTTP to communicate between two Web applications deployed on the same server, i.e. inside the same VM, seems a bit like an overkill. Therefore my question is if there is some sort of a local transport implementation that would allow to do this in a more efficient way. Obviously the local transport defined in Axis2 can't be used here, because it would require changes to the target application. Also the fact that each of the two Web applications has its own class loader would make this tricky.

It appears that the servlet specification actually defines a way for two Web applications hosted in the same container to communicate with each other directly, i.e. in VM. Indeed a Web application can obtain the ServletContext of another Web application using ServletContext#getContext. Usually the server must be configured to allow this kind of cross context access, but this is supported by Tomcat (by specifying crossContext="true" in the context file). Using this mechanism, the Web applications can communicate in two different ways:

* By sharing state using get/setAttribute.
* By acquiring a RequestDispatcher for a servlet from the foreign context and invoking forward or include on this object.

The first approach can be discarded, again because of class loader issues and the fact that it would require changes to the second application. The second approach is more promising because it allows to invoke the servlet that implements the target service. Note however that there is an important restriction imposed by the servlet specification on the use of RequestDispatcher#include/forward: "The request and response parameters must be either the same objects as were passed to the calling servlet’s service method or be subclasses of the ServletRequestWrapper or ServletResponseWrapper classes that wrap them." This means that these methods can't be called with arbitrary HttpServletRequest/Response implementations. Obviously this requirement is there to guarantee that the server gets access to the original request/response objects. It could be that some servers do not enforce this requirement, but for those that do, the practical consequence is that the RequestDispatcher approach would only work if the original request is received by SynapseAxisServlet, which is perfectly compatible with the use case described here.

My question is whether anybody on this list is aware of an existing Axis2 transport implementation that uses this approach or if anybody here sees any obstacle that would make it impossible to implement this kind of transport.

Regards,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to