/* * Copyright 2 1 by Sun Microsystems, Inc., * 9 1 San Antonio Road, Palo Alto, California, 943 3, U.S.A. * All rights reserved. * * This software is the confidential and proprietary information * of Sun Microsystems, Inc. ("Confidential Information" . You * shall not disclose such Confidential Information and shall use * it only in accordance with the terms of the license agreement * you entered into with Sun. */ package com.sun.xml.messaging.examples; 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 { public void onMessage(Message message) { System.out.println("onMessage of MyListener invoked"); try { //Get the first part which is the SOAPPart. SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope soapEnvelope = soapPart.getSOAPEnvelope(); DOMSource domSrc = (DOMSource) soapEnvelope.getContentAs(DOMSource.FEATURE); //Now use the dom tree to actually get traverse and //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"); } } } catch(Exception jxe) { jxe.printStackTrace(); } } }