use of org.springframework.xml.transform.StringResult in project spring-integration by spring-projects.
the class XsltPayloadTransformer method transformSource.
private Object transformSource(Source source, Object payload, Transformer transformer) throws TransformerException {
Result result;
if (!this.resultFactoryExplicitlySet && "text".equals(transformer.getOutputProperties().getProperty("method"))) {
result = new StringResult();
} else {
result = this.getResultFactory().createResult(payload);
}
transformer.transform(source, result);
if (this.resultTransformer != null) {
return this.resultTransformer.transformResult(result);
}
return result;
}
use of org.springframework.xml.transform.StringResult in project spring-integration by spring-projects.
the class XsltPayloadTransformerParserTests method testWithResourceAndStringResultType.
@Test
public void testWithResourceAndStringResultType() throws Exception {
MessageChannel input = (MessageChannel) applicationContext.getBean("withTemplatesAndStringResultTypeIn");
GenericMessage<Object> message = new GenericMessage<Object>(XmlTestUtil.getDomSourceForString(doc));
input.send(message);
Message<?> result = output.receive(0);
assertTrue("Payload was not a StringResult", result.getPayload() instanceof StringResult);
}
use of org.springframework.xml.transform.StringResult in project spring-integration-samples by spring-projects.
the class WeatherMarshaller method writeXml.
public static final void writeXml(Document document) {
Transformer transformer = createIndentingTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
try {
StringResult streamResult = new StringResult();
transformer.transform(new DOMSource(document), streamResult);
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
use of org.springframework.xml.transform.StringResult in project spring-integration-samples by spring-projects.
the class InContainerTests method testWebServiceRequestAndResponse.
@Test
public void testWebServiceRequestAndResponse() {
StringResult result = new StringResult();
Source payload = new StringSource("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<echoRequest xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoRequest>");
template.sendSourceAndReceiveToResult(WS_URI, payload, result);
logger.info("RESULT: " + result.toString());
assertThat(result.toString(), equalTo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<echoResponse xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoResponse>"));
}
use of org.springframework.xml.transform.StringResult in project spring-integration-samples by spring-projects.
the class XmlUtil method docAsString.
public static String docAsString(Document doc) {
try {
StringResult res = new StringResult();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(doc), res);
return res.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations