org.apache.soap.Envelope: How to read the returned envelope?
Bhiku Mhatre
Ranch Hand
Joined: Feb 11, 2002
Posts: 33
posted
0
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) { response.append(line); 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? Thanks!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: org.apache.soap.Envelope: How to read the returned envelope?