Here you can find the source of getElement(SOAPMessage message, String tagname, String nsURI, int whichOne)
Parameter | Description |
---|---|
message | The SOAP message to be searched with. |
tagname | The tag name of element to be retrieved. |
nsURI | The namespace URI. |
whichOne | The nth child element to be returned. |
public static SOAPElement getElement(SOAPMessage message, String tagname, String nsURI, int whichOne) throws SOAPException
//package com.java2s; /* /* ww w . j a v a 2 s. co m*/ * Copyright(c) 2005 Center for E-Commerce Infrastructure Development, The * University of Hong Kong (HKU). All Rights Reserved. * * This software is licensed under the GNU GENERAL PUBLIC LICENSE Version 2.0 [1] * * [1] http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt */ import javax.xml.soap.SOAPBody; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; import org.w3c.dom.NodeList; public class Main { /** * Get a SOAP Element from the SOAPMessage (SOAPbody inside). * * @param message The SOAP message to be searched with. * @param tagname The tag name of element to be retrieved. * @param nsURI The namespace URI. * @param whichOne The nth child element to be returned. * * @return The element in the tagname specified. */ public static SOAPElement getElement(SOAPMessage message, String tagname, String nsURI, int whichOne) throws SOAPException { if (message == null) // return null if the message is null. return null; // Get the soap body from the response. SOAPBody elementBody = message.getSOAPPart().getEnvelope().getBody(); if (elementBody == null) // return null if the body is null. return null; // Find all the child with the childname. NodeList nl = elementBody.getElementsByTagNameNS(nsURI, tagname); if (nl.getLength() <= whichOne) { return null; } return (SOAPElement) nl.item(whichOne); } }