• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Bhiku Mhatre
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic