Skip to main content

A Newbie looking for Help with parsing a reply from dispatch.invokeasync/response.get

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2011-10-17

I wonder if anyone can point me in the right direction.

I am calling a web service with the dispatch.invokeaysnc method and then getting the reply with get(). This I believe is actually giving me what I believe is a StAXSource object which I can convert to a string with a Transformer, StreamResult and StringWriter (see code below)

request = new StreamSource(new StringReader(requestStr));
                response = dispatch.invokeAsync(request);
                reply = (Source) response.get();
                    Transformer copier = TransformerFactory.newInstance().newTransformer();
                    StreamResult result = new StreamResult(new StringWriter());
                    copier.transform(reply, result);
                    String xmlString = result.getWriter().toString();

This all works fine but what I would really like to do is to use a the StAX cursor API to get parse my way through the response.

I have browsed loads of stuff on the web but can find nothing that gives me a clue as how to get the StAXSource into a useable form to even start to do this. The only code examples I have found for the cursor API starts with the data already in a XMLStreamReader which was read from a file.

I have spent hours on this and am getting nowhere.

Any help would be appreciated - Thanks