Create generic invoke method for RPC