use of org.springframework.ws.pox.dom.DomPoxMessage in project spring-integration by spring-projects.
the class StubMessageFactory method createWebServiceMessage.
public WebServiceMessage createWebServiceMessage(InputStream inputStream) throws IOException {
try {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource(new InputStreamReader(inputStream));
Document document = builder.parse(is);
return new DomPoxMessage(document, transformer, "text/xml");
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
}
use of org.springframework.ws.pox.dom.DomPoxMessage in project camel by apache.
the class BasicMessageFilterTest method nonSoapMessageShouldBeSkipped.
@Test
public void nonSoapMessageShouldBeSkipped() throws Exception {
DomPoxMessage domPoxMessage = new DomPoxMessageFactory().createWebServiceMessage();
filter.filterConsumer(exchange, domPoxMessage);
filter.filterProducer(exchange, domPoxMessage);
}
use of org.springframework.ws.pox.dom.DomPoxMessage in project spring-integration-samples by spring-projects.
the class InboundGatewayTests method testSendAndReceive.
/**
* Emulate the Spring WS MessageDispatcherServlet by calling the gateway
* with a DOMSource object representing the payload of the original SOAP
* 'echoRequest' message. Expect an 'echoResponse' DOMSource object
* to be returned in synchronous fashion, which the MessageDispatcherServlet
* would in turn wrap in a SOAP envelope and return to the client.
*/
@Test
public void testSendAndReceive() throws Exception {
String xml = "<echoRequest xmlns=\"http://www.springframework.org/spring-ws/samples/echo\">hello</echoRequest>";
DomPoxMessageFactory messageFactory = new DomPoxMessageFactory();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new InputSource(new StringReader(xml)));
Transformer transformer = TransformerFactory.newInstance().newTransformer();
DomPoxMessage request = new DomPoxMessage(document, transformer, "text/xml");
MessageContext messageContext = new DefaultMessageContext(request, messageFactory);
gateway.invoke(messageContext);
Object reply = messageContext.getResponse().getPayloadSource();
assertThat(reply, is(instanceOf(DOMSource.class)));
DOMSource replySource = (DOMSource) reply;
Element element = (Element) replySource.getNode().getFirstChild();
assertThat(element.getTagName(), equalTo("echoResponse"));
}
Aggregations