SOAPElement elem = (SOAPElement) soapBody.getChildElements().next();
SOAPElement elem = null; for (Iterator it = soapBody.getChildElements(); it.hasNext();) { Object child =  it.next(); if (child instanceof SOAPElement) { elem = (SOAPElement) child; break; } } if (elem == null) { throw new IllegalStateException("Could not find any element in soap body"); }
    public void toNMS(NormalizedMessage normalizedMessage, SOAPMessage soapMessage) throws MessagingException, SOAPException {        if (log.isDebugEnabled()) {        	try {	            ByteArrayOutputStream buffer = new ByteArrayOutputStream();	            soapMessage.writeTo(buffer);	            log.debug(new String(buffer.toByteArray()));        	} catch (Exception e) { }        }            	addNmsProperties(normalizedMessage, soapMessage);        SOAPPart soapPart = soapMessage.getSOAPPart();        SOAPBody soapBody = soapPart.getEnvelope().getBody();        SOAPElement elem = (SOAPElement) soapBody.getChildElements().next();                for (SOAPElement parent = elem.getParentElement(); parent != null; parent = parent.getParentElement()) {        	for (Iterator itNs = parent.getNamespacePrefixes(); itNs.hasNext();) {        		String prefix = (String) itNs.next();        		String nsuri = parent.getNamespaceURI(prefix);        		if (elem.getAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix) == null) {	        		elem.addNamespaceDeclaration(prefix, nsuri);	        		elem.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, nsuri);        		}        	}        }                if (log.isDebugEnabled()) {        	try {        		log.debug(transformer.toString(elem));        	} catch (Exception e) { }        }                normalizedMessage.setContent(new DOMSource(elem));        addNmsAttachments(normalizedMessage, soapMessage);    }