Here you can find the source of printReply(SOAPMessage reply)
public static void printReply(SOAPMessage reply) throws SOAPException
//package com.java2s; /*/*from w ww . j ava 2s . c o m*/ * ==================================================================== * This software is subject to the terms of the Common Public License * Agreement, available at the following URL: * http://www.opensource.org/licenses/cpl.html . * Copyright (C) 2003-2004 TONBELLER AG. * All Rights Reserved. * You must accept the terms of that agreement to use this software. * ==================================================================== * * */ import java.util.Iterator; import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; public class Main { /** * print reply to output to System.out */ public static void printReply(SOAPMessage reply) throws SOAPException { // Document source, do a transform. System.out.println("Reply:"); SOAPPart sp = reply.getSOAPPart(); SOAPEnvelope envelope = sp.getEnvelope(); SOAPBody body = envelope.getBody(); Iterator itBody = body.getChildElements(); while (itBody.hasNext()) { SOAPElement element = (SOAPElement) itBody.next(); printElement(element); } System.out.println(); } /** * recursively print element * @param el */ static private void printElement(SOAPElement el) { System.out.println(el.getElementName() + el.getValue()); Iterator itAtt = el.getAllAttributes(); if (itAtt.hasNext()) { System.out.print("<" + el.getElementName()); while (itAtt.hasNext()) { SOAPElement att = (SOAPElement) itAtt.next(); System.out.print(" " + att.getElementName() + "=" + att.getValue()); } System.out.println(">"); } else { System.out.println("<" + el.getElementName() + ">"); } System.out.println(el.getValue()); System.out.println("</" + el.getElementName() + ">"); Iterator it = el.getChildElements(); while (it.hasNext()) { SOAPElement element = (SOAPElement) it.next(); printElement(element); } } }