The idea is to have a client calling different webmethods but at the server side having all the calls redirected to one entry point where authentication/permissions are checked and then let the call continue. This is:
client side server side
------------ --------------
(proxy) del (delegate)
serv.foo(token, arg) ---------> entry_point:
if ok(token)
del.foo(arg) -----------> actual foo() implem.
serv.bar(token,arg1,arg2) ----> entry_point:
if ok(token)
del.bar(arg1,arg2) ----> actual bar() implem.
I have clear that the proxy is to be coded using reflection. The problem is how to redirect calls from client side to the proxy entry point. I've tried Dynamic proxy
in the server side: problem: the WS doesn't expose the interface methods (foo() bar()) to the client (the object to be published is the one returned by Proxy.newProxyInstance() and it doesn't have them)
in the client side: bar() and token() calls are redirected to the dynamic proxy invoke() method (great !). Then I try to forward the call to a WS with invoke() as the only webmethod (and same paramaters than the original method), BUT: problem: the WS can't hold the invoke parameters:
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
(it complains about the Method argument).
Any suggestion, or different approach?