Example usage for javax.xml.soap SOAPElement getValue

List of usage examples for javax.xml.soap SOAPElement getValue

Introduction

In this page you can find the example usage for javax.xml.soap SOAPElement getValue.

Prototype

public String getValue();

Source Link

Document

Returns the value of this node if this is a Text node or the value of the immediate child of this node otherwise.

Usage

From source file:ee.ria.xroad.common.message.SoapUtils.java

private static String getServiceCode(SOAPMessage soap, QName requestElementQName) throws SOAPException {
    for (SOAPElement eachHeaderElement : getChildElements(soap.getSOAPHeader())) {
        QName headerElementQName = eachHeaderElement.getElementQName();

        if (!"service".equals(headerElementQName.getLocalPart())) {
            continue;
        }// w ww.j  a va 2  s  .co  m

        for (SOAPElement eachServicePart : getChildElements(eachHeaderElement)) {
            QName headerPartQName = eachServicePart.getElementQName();

            if (headerPartQName.getLocalPart().equals("serviceCode")) {
                return eachServicePart.getValue();
            }
        }
    }

    return requestElementQName.getLocalPart();
}

From source file:com.polivoto.networking.SoapClient.java

public String start() throws SOAPException, IOException {
    String resp = "NaN";
    // Create SOAP Connection
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection = soapConnectionFactory.createConnection();

    // Send SOAP Message to SOAP Server
    String url = "http://" + host
            + "/FistVotingServiceBank/services/ServAvailableVoteProcesses.ServAvailableVoteProcessesHttpSoap11Endpoint/";
    SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

    SOAPBody body = soapResponse.getSOAPBody();
    java.util.Iterator updates = body.getChildElements();
    // El siguiente ciclo funciona slo porque el cuerpo contiene 
    // un elemento y ste a suvez nicamente contiene un elemento.
    while (updates.hasNext()) {
        System.out.println();/*from  ww w .  j a va  2  s  .co  m*/
        // The listing and its ID
        SOAPElement update = (SOAPElement) updates.next();
        java.util.Iterator i = update.getChildElements();
        while (i.hasNext()) {
            SOAPElement e = (SOAPElement) i.next();
            String name = e.getLocalName();
            String value = e.getValue();
            resp = value; // Am I getting last response?
            System.out.println(name + ": " + value);
        }
    }
    soapConnection.close();
    return resp;
}

From source file:hk.hku.cecid.corvus.ws.EBMSMessageHistoryQuerySenderTest.java

private String getElementValue(SOAPElement msgBody, String name) {
    Iterator iterator = msgBody.getChildElements();
    while (iterator.hasNext()) {
        SOAPElement current = (SOAPElement) iterator.next();
        if (current.getNodeName().equalsIgnoreCase(name))
            return current.getValue();
    }/*from   w w w.j  a v a 2s  .co  m*/
    return null;
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test//from  w  w w .  j  a  v a 2  s.  c  o m
public void testGetValueNoChildren() throws Exception {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    assertNull(element.getValue());
}

From source file:net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuter.java

protected void handleCellErrors(Iterator<?> errorElems) throws SOAPException {
    SOAPElement errorElem = (SOAPElement) errorElems.next();

    StringBuilder errorMsg = new StringBuilder();
    errorMsg.append("Cell error: ");

    Iterator<?> descriptionElems = errorElem.getChildElements(sf.createName("Description", "", MDD_URI));
    if (descriptionElems.hasNext()) {
        SOAPElement descrElem = (SOAPElement) descriptionElems.next();
        errorMsg.append(descrElem.getValue());
        errorMsg.append("; ");
    }//w ww.  j  a  va2  s.com

    Iterator<?> sourceElems = errorElem.getChildElements(sf.createName("Source", "", MDD_URI));
    if (sourceElems.hasNext()) {
        SOAPElement sourceElem = (SOAPElement) sourceElems.next();
        errorMsg.append("Source: ");
        errorMsg.append(sourceElem.getValue());
        errorMsg.append("; ");
    }

    Iterator<?> codeElems = errorElem.getChildElements(sf.createName("ErrorCode", "", MDD_URI));
    if (codeElems.hasNext()) {
        SOAPElement codeElem = (SOAPElement) codeElems.next();
        errorMsg.append("Code: ");
        errorMsg.append(codeElem.getValue());
        errorMsg.append("; ");
    }

    throw new JRRuntimeException(errorMsg.toString());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test/*from w  w w  .  j  a va 2  s .  c  om*/
public void testGetValueSingleTextChild() throws Exception {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.addTextNode("test");
    assertEquals("test", element.getValue());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test/*from w  w  w  . j  a  va2 s. c om*/
public void testSetValueNoChildren() {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    String value = "test";
    element.setValue(value);
    assertEquals(value, element.getValue());
    Node child = element.getFirstChild();
    assertTrue(child instanceof Text);
    assertEquals(value, ((Text) child).getValue());
    assertNull(child.getNextSibling());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test//from   www.j av a2s.  c  o m
public void testGetValueSingleElementChild() throws Exception {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.appendChild(element.getOwnerDocument().createElementNS("urn:ns", "p:child"));
    assertNull(element.getValue());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

@Validated
@Test//from  w ww .j a v a2  s .  co  m
public void testGetValueTwoTextChildren() throws Exception {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.addTextNode("foo");
    element.addTextNode("bar");
    assertEquals(2, element.getChildNodes().getLength());
    assertEquals("foobar", element.getValue());
}

From source file:net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuter.java

protected void parseCellDataElement(SOAPElement cellDataElement) throws SOAPException {
    Name name = sf.createName("Cell", "", MDD_URI);
    Iterator<?> itCells = cellDataElement.getChildElements(name);
    while (itCells.hasNext()) {
        SOAPElement cellElement = (SOAPElement) itCells.next();

        Name errorName = sf.createName("Error", "", MDD_URI);
        Iterator<?> errorElems = cellElement.getChildElements(errorName);
        if (errorElems.hasNext()) {
            handleCellErrors(errorElems);
        }//from w w  w  . j  a v a 2s.  co m

        Name ordinalName = sf.createName("CellOrdinal");
        String cellOrdinal = cellElement.getAttributeValue(ordinalName);

        Object value = null;
        Iterator<?> valueElements = cellElement.getChildElements(sf.createName("Value", "", MDD_URI));
        if (valueElements.hasNext()) {
            SOAPElement valueElement = (SOAPElement) valueElements.next();
            String valueType = valueElement.getAttribute("xsi:type");
            if (valueType.equals("xsd:int")) {
                value = Long.valueOf(valueElement.getValue());
            } else if (valueType.equals("xsd:double") || valueType.equals("xsd:decimal")) {
                value = Double.valueOf(valueElement.getValue());
            } else {
                value = valueElement.getValue();
            }
        }

        String fmtValue = "";
        Iterator<?> fmtValueElements = cellElement.getChildElements(sf.createName("FmtValue", "", MDD_URI));
        if (fmtValueElements.hasNext()) {
            SOAPElement fmtValueElement = ((SOAPElement) fmtValueElements.next());
            fmtValue = fmtValueElement.getValue();
        }

        int pos = Integer.parseInt(cellOrdinal);
        JRXmlaCell cell = new JRXmlaCell(value, fmtValue);
        xmlaResult.setCell(cell, pos);
    }
}