Example usage for javax.xml.soap Node getNodeType

List of usage examples for javax.xml.soap Node getNodeType

Introduction

In this page you can find the example usage for javax.xml.soap Node getNodeType.

Prototype

public short getNodeType();

Source Link

Document

A code representing the type of the underlying object, as defined above.

Usage

From source file:org.libreplan.importers.TimSoapClient.java

/**
 * Unmarshals the specified paramter <code>soapBody</code> to the specified
 * <code>clazz</code>//from  ww w  . ja va2 s.  c om
 *
 * @param clazz
 *            object to hold unmarashal result
 * @param soapBody
 *            the soap body to be unmarshalled
 * @return the unmarashalled object
 * @throws JAXBException
 *             if unmarshal failed
 */
@SuppressWarnings("unchecked")
private static <T> T unmarshal(Class<T> clazz, SOAPBody soapBody) throws JAXBException {
    JAXBContext jaxbContext = JAXBContext.newInstance(clazz);

    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    Node bindElement = (Node) soapBody.getFirstChild();

    while (bindElement.getNodeType() != Node.ELEMENT_NODE) {
        bindElement = (Node) bindElement.getNextSibling();
    }

    return unmarshaller.unmarshal(bindElement, clazz).getValue();
}