String rawXml = "<![CDATA[<some-data><some-data-item>1</some-data-item></some-data>]]>"; // Start the API MessageFactory mf = MessageFactory.newInstance(); SOAPMessage request = mf.createMessage(); SOAPPart part = request.getSOAPPart(); SOAPEnvelope env = part.getEnvelope(); // Get the body. How do I add the raw xml directly into the body? SOAPBody body = env.getBody(); SOAPElement se = body.addTextNode(rawXml); System.out.println(body.getTextContent());
@Test public void test1() throws Exception { SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody(); QName payloadName = new QName( "http://soap.jax.drools.org", "execute", "ns1" ); body.addBodyElement( payloadName ); String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += " <insert out-identifier=\"salaboy\" disconnected=\"true\">\n"; cmd += " <org.drools.pipeline.camel.Person>\n"; cmd += " <name>salaboy</name>\n"; cmd += " <age>27</age>\n"; cmd += " </org.drools.pipeline.camel.Person>\n"; cmd += " </insert>\n"; cmd += " <fire-all-rules/>\n"; cmd += "</batch-execution>\n"; body.addTextNode( cmd ); Object object = this.context.createProducerTemplate().requestBody( "direct://http", soapMessage ); OutputStream out = new ByteArrayOutputStream(); out = new ByteArrayOutputStream(); soapMessage = (SOAPMessage) object; soapMessage.writeTo( out ); String response = out.toString(); assertTrue( response.contains( "fact-handle identifier=\"salaboy\"" ) ); }
@Test public void test1() throws Exception { SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPBody body = soapMessage.getSOAPPart().getEnvelope().getBody(); QName payloadName = new QName("http://soap.jax.drools.org", "execute", "ns1"); body.addBodyElement(payloadName); String cmd = ""; cmd += "<batch-execution lookup=\"ksession1\">\n"; cmd += " <insert out-identifier=\"salaboy\" disconnected=\"true\">\n"; cmd += " <org.kie.pipeline.camel.Person>\n"; cmd += " <name>salaboy</name>\n"; cmd += " <age>27</age>\n"; cmd += " </org.kie.pipeline.camel.Person>\n"; cmd += " </insert>\n"; cmd += " <fire-all-rules/>\n"; cmd += "</batch-execution>\n"; body.addTextNode(cmd); Object object = this.context.createProducerTemplate().requestBody("direct://http", soapMessage); OutputStream out = new ByteArrayOutputStream(); out = new ByteArrayOutputStream(); soapMessage = (SOAPMessage)object; soapMessage.writeTo(out); String response = out.toString(); assertTrue(response.contains("fact-handle identifier=\"salaboy\"")); }
cmd += "</batch-execution>\n"; body.addTextNode(cmd); cmd2 += "</batch-execution>\n"; body2.addTextNode(cmd2);
cmd += "</batch-execution>\n"; body.addTextNode( cmd ); cmd2 += "</batch-execution>\n"; body2.addTextNode( cmd2 );
secElement.appendChild(soapPart.importNode(authorizationAssertion.getDOM(), true)); secElement.appendChild(soapPart.importNode(auditingAssertion.getDOM(), true)); soapBody.addTextNode("$RequestXMLPlaceHolder");
secElement.addChildElement(authorizationHeaderName).appendChild(soapPart.importNode(authorizationAssertion.getDOM(), true)); secElement.addChildElement(auditingHeaderName).appendChild(soapPart.importNode(auditingAssertion.getDOM(), true)); soapBody.addTextNode("$RequestXMLPlaceHolder");