Mar 21st, 2007, 08:25 AM
passing information to the underlying httpClient
Our application has two tomcat server; TomcatA uses Spring remoting (apache commons HttpClient) to make service/remote calls to tomcatB.
Users connect to tomcatA and that's where there credentials are validated; The current interfaces/api to the remote methods does not provide for any facility for passing any additional parameters/arguments and our requirement is now to pass the user credentials (or at least the username) to tomcatB from tomcatA for logging purposes as to which user invoked the remote method.
Is there anyway that we can pass each user's information when the application invokes the remote method to the underlying commons http client via the spring framework so that it can be retrieved at the server (tomcatB) ?
Any suggestions are appreciated, Many thanks
Last edited by rishiasthana; Mar 21st, 2007 at 08:29 AM.
Mar 21st, 2007, 09:06 AM
There is an obvious AOP solution: wrap both the client and sever side in a Proxy - on the client to add the user credentials to the call, and one on the server to log them and delegate to the real remote service.
Mar 21st, 2007, 09:15 AM
Thanks for the reply david_syer.
AOP was the first thing that popped up in our collective minds as well but unfortunately it is not an option as it has not yet been approved for use in our org.
Mar 22nd, 2007, 03:01 AM
You can't use java.lang.reflect.Proxy? If you can, then the good news is that that is what Spring AOP uses. If you can't for some bizarre reason (how would anyone know?), then the bad news is that you're already using it with HttpInvoker.
Last edited by Dave Syer; Mar 22nd, 2007 at 04:29 AM.
Mar 28th, 2007, 04:10 PM
What's the best way to wrap the client in a proxy? Implement my own httpInvokerRequestExecutor, containing an HttpClientFactoryBean?
Or is there an easier way?
Mar 29th, 2007, 12:49 PM
I would wrap your client in a Proxy with some advice that adds the user credentials (nothing to do with http invoker). Then expose a different interface using HttpInvoker, adding the client credentials as an extra argument.