List of usage examples for javax.xml.soap SOAPElement getChildElements
public Iterator<Node> getChildElements();
From source file:org.freebxml.omar.common.BindingUtility.java
public SOAPElement getSOAPElementFromBindingObject(Object obj) throws JAXRException { SOAPElement soapElem = null;/*from w ww.j av a 2s . c o m*/ try { SOAPElement parent = SOAPFactory.newInstance().createElement("dummy"); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(obj, new DOMResult(parent)); soapElem = (SOAPElement) parent.getChildElements().next(); } catch (Exception e) { throw new JAXRException(e); } return soapElem; }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
/** * Gets the first child element of the given SOAP element with the specified namespace URI and * local name. This overload is necessary as method {@link Node#getNextSibling()} does not behave * as expected under some SAAJ implementations. * @param parent the parent node to examine * @param namespaceURI the namespace URI of the desired child element; if <code>null</code>, * only elements with a <code>null</code> or empty namespace URI will be considered * @param localName the local name of the desired child element * @return the corresponding child element, or <code>null</code> if there is no match *//*from w ww. jav a2 s . c o m*/ public static SOAPElement getElement(SOAPElement parent, String namespaceURI, String localName) { Iterator childIt = parent.getChildElements(); while (childIt.hasNext()) { javax.xml.soap.Node child = (javax.xml.soap.Node) childIt.next(); if (XmlUtil.nodeNameEquals(child, namespaceURI, localName)) return (SOAPElement) child; } return null; }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
/** * Gets the first child element of the given SOAP element. * @param parent the parent SOAP element to examine * @return the corresponding child element, or <code>null</code> if there is no match *///from ww w . ja va 2s .c o m public static SOAPElement getElement(SOAPElement parent) { Iterator childIt = parent.getChildElements(); while (childIt.hasNext()) { Object child = childIt.next(); if (child instanceof SOAPElement) return (SOAPElement) child; } return null; }
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
public static void copyChildNodes(Element target, SOAPElement source) { // easy way out: no child nodes to copy if (!source.hasChildNodes()) return;/*from w w w. j av a 2s . c o m*/ // traverse child nodes Iterator childIt = source.getChildElements(); while (childIt.hasNext()) { Object child = childIt.next(); if (child instanceof SOAPElement) { copyChildElement(target, (SOAPElement) child); } else if (child instanceof Text) { Text childText = (Text) child; String value = childText.getValue(); target.appendChild(target.getOwnerDocument().createTextNode(value)); if (traceEnabled) log.trace("appended text: " + value); } else log.debug("discarding child: " + child); } }
From source file:org.jbpm.bpel.integration.soap.SoapUtilTest.java
public void testRemoveChildNodes_soap() throws Exception { String xml = "<soap:Envelope xmlns:soap='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>" + " <soap:Body xmlns:fish='urn:example:fish'>" + " <meal:lunch xmlns:produce='urn:example:produce'" + " xmlns:meal='urn:example:meal'>" + " <time>1200</time>" + " <produce:lettuce>0.1lb</produce:lettuce>" + " <fish:fillet xmlns:fish='urn:example:fish'>0.25lb</fish:fillet>" + " </meal:lunch>" + " </soap:Body>" + "</soap:Envelope>"; ByteArrayInputStream sourceStream = new ByteArrayInputStream(xml.getBytes()); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(null, sourceStream); SOAPElement element = SoapUtil.getElement(soapMessage.getSOAPBody(), "urn:example:meal", "lunch"); // remove the child nodes element.removeContents();//from w w w. ja v a 2 s .c o m // verify remotion assertFalse(element.getChildElements().hasNext()); }
From source file:org.olat.modules.vitero.manager.ViteroManager.java
private String extractErrorCode(SOAPElement element) { if (element == null) return null; for (Iterator<?> it = element.getChildElements(); it.hasNext();) { Object childElement = it.next(); if (childElement instanceof SOAPElement) { SOAPElement soapElement = (SOAPElement) childElement; String nodeName = soapElement.getNodeName(); if ("errorCode".equals(nodeName)) { return extractText(soapElement); } else { extractErrorCode(soapElement); }/* w w w.j a v a2s . c o m*/ } } return null; }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * retrieve data source properties// w w w . jav a 2 s . c o m * * @return Map of key/value strings * @see DataSourceBrowser */ public Map discoverDS() throws XMLAException { // Microsoft wants restrictions HashMap rHash = new HashMap(); HashMap pHash = new HashMap(); pHash.put("Content", "Data"); //$NON-NLS-1$ //$NON-NLS-2$ final Map resultMap = new HashMap(); Rowhandler rh = new Rowhandler() { public void handleRow(SOAPElement eRow, SOAPEnvelope envelope) { /* * <row><DataSourceName>SAP_BW</DataSourceName> <DataSourceDescription>SAP BW Release 3.0A XML f. Analysis * Service</DataSourceDescription> <URL>http://155.56.49.46:83/SAP/BW/XML/SOAP/XMLA</URL> * <DataSourceInfo>default</DataSourceInfo> <ProviderName>SAP BW</ProviderName> <ProviderType>MDP</ProviderType> * <AuthenticationMode>Integrated</AuthenticationMode></row> */ Iterator it = eRow.getChildElements(); while (it.hasNext()) { Object o = it.next(); if (!(o instanceof SOAPElement)) { continue; // bypass text nodes } SOAPElement e = (SOAPElement) o; String name = e.getElementName().getLocalName(); String value = e.getValue(); resultMap.put(name, value); } } }; discover("DISCOVER_DATASOURCES", url, rHash, pHash, rh); //$NON-NLS-1$ debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0005_DISCOVER_DATASOURCE_FOUND") + resultMap.size()); //$NON-NLS-1$ return resultMap; }
From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java
/** * Find the Provider type in the DiscoverResponse * * @param n/*from w ww . ja v a 2 s . c o m*/ * @return * @throws XMLAException * @throws SOAPException */ private int getProviderFromDiscoverResponse(final SOAPEnvelope envelope, final SOAPElement e) throws XMLAException, SOAPException { Name name = e.getElementName(); if (!name.getLocalName().equals("DiscoverResponse")) { //$NON-NLS-1$ throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0018_NOT_A_DISCOVER_RESPONSE") //$NON-NLS-1$ + name.getLocalName()); } // Look for return/root/row/ProviderName SOAPElement walker = getDiscoverReturn(envelope, e); if (walker == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0019_NO_RESULT_DISCOVER_RESPONSE")); //$NON-NLS-1$ } walker = getDiscoverRoot(envelope, walker); if (walker == null) { throw new XMLAException(Messages.getInstance() .getString("XMLABaseComponent.ERROR_0020_NO_RESULT_DISCOVER_RETURN_ROOT")); //$NON-NLS-1$ } walker = getDiscoverRow(envelope, walker); if (walker == null) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0021_NO_DISCOVER_RESPONSE_ROW")); //$NON-NLS-1$ } /* * Name nProviderName = envelope.createName("ProviderName", "", ROWS_URI); SOAPElement eProviderName = * selectSingleNode(e, nProviderName); * * if (eProviderName == null) { throw new OlapException("Discover result has no * DiscoverResponse/return/root/row/ProviderName element"); } value = eProviderName.getValue(); */ String value = null; Iterator it = walker.getChildElements(); while (it.hasNext()) { Object o = it.next(); if (!(o instanceof SOAPElement)) { continue; // bypass text nodes } SOAPElement e2 = (SOAPElement) o; String nameString = e2.getElementName().getLocalName(); if (nameString.equals("ProviderName")) { //$NON-NLS-1$ value = e2.getValue(); debug(Messages.getInstance().getString("XMLABaseComponent.DEBUG_0008_FOUND_PROVIDER") + value); //$NON-NLS-1$ break; } } if ((value == null) || (value.trim().length() == 0)) { throw new XMLAException( Messages.getInstance().getString("XMLABaseComponent.ERROR_0022_NO_PROVIDER_NAME_ELEMENT")); //$NON-NLS-1$ } return determineProvider("Provider=" + value); //$NON-NLS-1$ }