Parallel invoking list async webservice client

I’ve a webservice client that invokes several webservices with same wsdl on different endpoint, so I decided to make asynchronous calls in a parallel way. I generated wsimport async jax-ws client and I decided to use a Future invocation with Async callback (using a single AsyncHandler instance for all the futures operation),

The question is: is there a way in the handleResponse(Response response) method to know to which of the future in the futures list the response is referred? Anything that can be done in the request context and propagate to reponse context? Should I indeed preserve a state in the AsyncHandler and instatiate a new Handler foreach future operation and store the response in a shared list (maybe a thread safe class member)?

Is there a way to Propagate Request Context to the Response as in here? [][1]

Thanks all. My snippet:

        WsSoapClient ws = new ....;

        List<Future> futures = new ArrayList<>();

        for (String url : urlList) {

            BindingProvider bp = (BindingProvider) ws;
            bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);

            Future invokeAsync = ws.getAsync("foo", mh);
        -> {
            try {

                t.get(15L, TimeUnit.SECONDS);
            } catch (InterruptedException | ExecutionException | TimeoutException ex) {

class MessageHandler implements AsyncHandler<String> {

        private final List<String> responses;

        public MessageHandler() {
            List<String> rr = new ArrayList<>();
            responses = Collections.synchronizedList(rr);

        public void handleResponse(Response<String> response) {
            try {

                String get = response.get();
            } catch (Exception e) {

        public List<String> getResponses() {
            return responses;




I ended up implementing a custom callback handler that mantains a state. One different instance for each future.

Source: stackoverflow