List of usage examples for javax.xml.soap SOAPElement addTextNode
public SOAPElement addTextNode(String text) throws SOAPException;
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//from ww w. j av a 2s .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:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/*from www .j a v a2s . com*/ public void testGetValueMixedContent1() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.addTextNode("foo"); element.appendChild(element.getOwnerDocument().createElementNS("urn:ns", "p:child")); element.addTextNode("bar"); assertEquals("foo", element.getValue()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/*from ww w. j a v a 2 s .c o m*/ public void testSetValueSingleTextChild() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.addTextNode("initial content"); Text text = (Text) element.getFirstChild(); String value = "new value"; element.setValue(value); assertEquals(value, text.getValue()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Tests the behavior of {@link SOAPElement#getChildElements()} when there are text nodes among * the children of the element. In contrast to what the name of the method suggests, they will * also be returned by the iterator./*from w ww . ja v a2s. com*/ * * @throws Exception */ @Validated @Test public void testGetChildElementsWithTextNodes() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.addTextNode("foo"); element.addChildElement(new QName("child")); element.addTextNode("bar"); Iterator it = element.getChildElements(); assertTrue(it.hasNext()); assertTrue(it.next() instanceof Text); assertTrue(it.hasNext()); assertTrue(it.next() instanceof SOAPElement); assertTrue(it.hasNext()); assertTrue(it.next() instanceof Text); assertFalse(it.hasNext()); }
From source file:net.sf.jasperreports.olap.xmla.JRXmlaQueryExecuter.java
protected SOAPMessage createQueryMessage() { String queryStr = getQueryString(); if (log.isDebugEnabled()) { log.debug("MDX query: " + queryStr); }//from w w w . j a va2 s .c o m try { MessageFactory mf = MessageFactory.newInstance(); SOAPMessage message = mf.createMessage(); MimeHeaders mh = message.getMimeHeaders(); mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\""); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); Name nEx = envelope.createName("Execute", "", XMLA_URI); SOAPElement eEx = body.addChildElement(nEx); // add the parameters // COMMAND parameter // <Command> // <Statement>queryStr</Statement> // </Command> Name nCom = envelope.createName("Command", "", XMLA_URI); SOAPElement eCommand = eEx.addChildElement(nCom); Name nSta = envelope.createName("Statement", "", XMLA_URI); SOAPElement eStatement = eCommand.addChildElement(nSta); eStatement.addTextNode(queryStr); // <Properties> // <PropertyList> // <DataSourceInfo>dataSource</DataSourceInfo> // <Catalog>catalog</Catalog> // <Format>Multidimensional</Format> // <AxisFormat>TupleFormat</AxisFormat> // </PropertyList> // </Properties> Map<String, String> paraList = new HashMap<String, String>(); String datasource = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_DATASOURCE); paraList.put("DataSourceInfo", datasource); String catalog = (String) getParameterValue(JRXmlaQueryExecuterFactory.PARAMETER_XMLA_CATALOG); paraList.put("Catalog", catalog); paraList.put("Format", "Multidimensional"); paraList.put("AxisFormat", "TupleFormat"); addParameterList(envelope, eEx, "Properties", "PropertyList", paraList); message.saveChanges(); if (log.isDebugEnabled()) { log.debug("XML/A query message: \n" + prettyPrintSOAP(message.getSOAPPart().getEnvelope())); } return message; } catch (SOAPException e) { throw new JRRuntimeException(e); } }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/*w ww. j a v a 2s . co m*/ public void testAddTextNode() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); SOAPElement returnValue = element.addTextNode("text"); assertSame(element, returnValue); assertEquals("text", element.getTextContent()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
/** * Checks the behavior of {@link SOAPElement#addTextNode(String)} when called with a string that * contains a character that is invalid according to the XML specification. The reference * implementation doesn't check for invalid characters. * // w w w . j a va 2s . c om * @throws Exception */ @Validated @Test public void testAddTextNodeWithInvalidChar() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); String testString = String.valueOf((char) 24); element.addTextNode(testString); assertEquals(testString, element.getTextContent()); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test/*from w ww. j ava 2 s. c om*/ public void testGetValueMixedContent2() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); element.appendChild(element.getOwnerDocument().createElementNS("urn:ns", "p:child1")); element.addTextNode("foo"); element.appendChild(element.getOwnerDocument().createElementNS("urn:ns", "p:child2")); element.addTextNode("bar"); assertEquals("foo", element.getValue()); }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.olap.OLAPQueryExecuter.java
protected void addParameterList(SOAPEnvelope envelope, SOAPElement eParent, String typeName, String listName, Map params) throws SOAPException { Name nPara = envelope.createName(typeName, "", XMLA_URI); SOAPElement eType = eParent.addChildElement(nPara); nPara = envelope.createName(listName, "", XMLA_URI); SOAPElement eList = eType.addChildElement(nPara); if (params == null) return;/*from ww w. ja v a 2 s . c o m*/ Iterator it = params.keySet().iterator(); while (it.hasNext()) { String tag = (String) it.next(); String value = (String) params.get(tag); nPara = envelope.createName(tag, "", XMLA_URI); SOAPElement eTag = eList.addChildElement(nPara); eTag.addTextNode(value); } }
From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.olap.OLAPQueryExecuter.java
protected SOAPMessage createQueryMessage(JRXMLADataSourceConnection xmlaConnection) { String queryStr = getQueryString(); if (log.isDebugEnabled()) { log.debug("MDX query: " + queryStr); }//from w w w. j a v a 2 s . co m try { // Force the use of Axis as message factory... MessageFactory mf = MessageFactory.newInstance(); SOAPMessage message = mf.createMessage(); MimeHeaders mh = message.getMimeHeaders(); mh.setHeader("SOAPAction", "\"urn:schemas-microsoft-com:xml-analysis:Execute\""); //mh.setHeader("Content-Type", "text/xml; charset=utf-8"); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); Name nEx = envelope.createName("Execute", "", XMLA_URI); SOAPElement eEx = body.addChildElement(nEx); // add the parameters // COMMAND parameter // <Command> // <Statement>queryStr</Statement> // </Command> Name nCom = envelope.createName("Command", "", XMLA_URI); SOAPElement eCommand = eEx.addChildElement(nCom); Name nSta = envelope.createName("Statement", "", XMLA_URI); SOAPElement eStatement = eCommand.addChildElement(nSta); eStatement.addTextNode(queryStr); // <Properties> // <PropertyList> // <DataSourceInfo>dataSource</DataSourceInfo> // <Catalog>catalog</Catalog> // <Format>Multidimensional</Format> // <AxisFormat>TupleFormat</AxisFormat> // </PropertyList> // </Properties> Map paraList = new HashMap(); String datasource = xmlaConnection.getDatasource(); paraList.put("DataSourceInfo", datasource); String catalog = xmlaConnection.getCatalog(); paraList.put("Catalog", catalog); paraList.put("Format", "Multidimensional"); paraList.put("AxisFormat", "TupleFormat"); addParameterList(envelope, eEx, "Properties", "PropertyList", paraList); message.saveChanges(); if (log.isDebugEnabled()) { log.debug("XML/A query message: " + message.toString()); } return message; } catch (SOAPException e) { log.error(e); throw new JRRuntimeException(e); } }