permaculture playing cards*
The moose likes Web Services and the fly likes org.apache.soap.Envelope: How to read the returned envelope? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "org.apache.soap.Envelope: How to read the returned envelope?" Watch "org.apache.soap.Envelope: How to read the returned envelope?" New topic

org.apache.soap.Envelope: How to read the returned envelope?

Bhiku Mhatre
Ranch Hand

Joined: Feb 11, 2002
Posts: 33
I form an Envelope and Message object using Apache SOAP. I send it using Message.send().
Then, all the common examples say that you should read the response like this:
-----org.apache.soap.transport.SOAPTransport st = msg.getSOAPTransport();
BufferedReader br = st.receive();
String line = br.readLine();
StringBuffer response = new StringBuffer();
if (line==null)
return null;
while(line!=null) {
line = br.readLine();
return response.toString(); // Return the Response
[The output is a valid SOAP Packet with the actual response I am interested in, inside the <Body> tag.]
However, the problem here is, the response is the SOAP Envelope itself, and I don't mean to return an envelope. I mean to return the Body-content of it. So I prepare the Envelope object from the response string - using Envelope.unmarshall() method. After this, I fail to retrieve the body-content. I use Envelope.getBodyParts() etc methods, which do return me the first entry - but I am not sure how to retrieve the whole XML that is contained within the Body tag. Assuming that acceptDoc was the method name on the SOAP server which returned the envelope - getBodyParts(); when printed out look like this
[Attributes={}] [BodyEntries=
[(0)=[acceptDoc: null]]
I am dumbfounded to see that 'null' and don't know how should I retrieve the Body part (XML string). Can anybody please help me?
I agree. Here's the link:
subject: org.apache.soap.Envelope: How to read the returned envelope?
Similar Threads
SAAJ (SOAP 1.1) incompatibility with Java 1.6
SOAP response is losing Body content data
Reading XML from Servlet request
Quest to make Client SOAP freely communicate with a SOAP service
HttpException: Already used, but not recycled.