/* * adapted from a sun example */ import javax.xml.messaging.*; import javax.xml.soap.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.activation.DataHandler; import java.io.*; import org.w3c.dom.*; import org.xml.sax.SAXException; public class SOAPListener extends JAXMServlet implements AsyncListener { // implement the required onMessage method public void onMessage(Message message) { try { //Get the soap part of the message (ignore attachments) SOAPPart soapPart = message.getSOAPPart( ); // tunnel in and get the envelope SOAPEnvelope soapEnvelope = soapPart.getSOAPEnvelope( ); // from the envelope get the DOM tree representing the content. DOMSource domSrc = (DOMSource) soapEnvelope.getContentAs(DOMSource.FEATURE ); //Now use the dom tree to traverse the info. //get some of the fields from it. Document doc = (Document) domSrc.getNode(); Element root = doc.getDocumentElement(); NodeList list = root.getElementsByTagName("GetLastTradePriceDetailed" ); Element element; Element childElement; for(int i = ; i < list.getLength(); i++){ if (!(list.item(i) instanceof Element )) continue; element = (Element list.item(i) ); NodeList list2 = element.getChildNodes(); for(int j = ; j < list2.getLength( ; j++ { if(!(list2.item(j instanceof Element) continue; childElement = (Element list2.item(j ; System.out.println(childElement.getTagName() ; System.out.println("\t" ; System.out.println( ((Text) childElement.getFirstChild()).getData()) ; System.out.println("\n" ); } } } // end try catch(Exception jxe ) { jxe.printStackTrace(); } } // end onMessage } // end SOAPListener