Skip to main content

Can't parse SAAJ return SOAPMessage

1 reply [Last post]
freelick
Offline
Joined: 2007-05-07

Hi,

This may not be the best forum for posting my question, but I have not been able locate an "ideal" forum. If I'm wondering down the wrong hall, please point me in the right direction. If you have advice on how to solve my problem, I would be eternally grateful.

Problem: I can't parse response SOAPMessage from a web service called using SAAJ to send a request SOAPMessage.

software Versions: I'm using Java 1.5.08 SE, JWSDP 2.0, Axis1-4, and BEA Weblogic 8.6.

Details. I can construct SOAPMessages, send them to my web service and receive a response SOAPMessage. I can even print the response message using two different methods.

print method 1: response.writeto(System.out)

print method2:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
Source sourceContent = reply.getSOAPPart().getContent();
StreamResult result = new StreamResult(System.out);
transformer.transform(sourceContent, result);

Both print methods display the SOAPMessge reply that I'm expecting. So, I conclude the basic creating, sending and receiving of the SOAPMessages is working correctly.

The real problem comes in when I try to extract (parse) data from the reply message. For example, the following line of code

NodeList nodeList = reply.getSOAPPart().getElementsByTagName("amountOfFuel");

Produces the following exception.

ERROR: 'NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.' May 8, 2007 8:01:10 AM com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope

SEVERE: SAAJ0511: Unable to create envelope from given source

Or, the following code

SOAPBody body = message.getSOAPBody();

Produces this error:

ERROR: 'NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.' May 8, 2007 8:16:07 AM com.sun.xml.messaging.saaj.soap.EnvelopeFactory createEnvelope

SEVERE: SAAJ0511: Unable to create envelope from given source

Everything I've read (tutorials, Google search results, books, etc) indicates each of the above code fragments should work.

I'm at a complete loss. If anybody has advice on the problem or can direct me to the correct forum, I thank you in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
spericas
Offline
Joined: 2003-06-10

I suggest that you try this forum first,

http://forums.java.net/jive/forum.jspa?forumID=46&start=0

and come back to the JAXP forum if you feel the problem is JAXP related. Hopefully, some SAAJ expert can help you out.