use of org.springframework.ws.client.core.WebServiceMessageCallback in project spring-integration by spring-projects.
the class WebServiceOutboundGatewayParserTests method marshallingGatewayWithCustomRequestCallback.
@Test
public void marshallingGatewayWithCustomRequestCallback() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
AbstractEndpoint endpoint = (AbstractEndpoint) context.getBean("gatewayWithCustomRequestCallback");
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object gateway = TestUtils.getPropertyValue(endpoint, "handler");
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
context.close();
}
use of org.springframework.ws.client.core.WebServiceMessageCallback in project camel by apache.
the class SpringWebserviceProducer method process.
public void process(Exchange exchange) throws Exception {
// Let Camel TypeConverter hierarchy handle the conversion of XML messages to Source objects
Source sourcePayload = exchange.getIn().getMandatoryBody(Source.class);
// Extract optional headers
String endpointUriHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ENDPOINT_URI, String.class);
String soapActionHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_ACTION, String.class);
URI wsAddressingActionHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_ACTION, URI.class);
URI wsReplyToHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_REPLY_TO, URI.class);
URI wsFaultToHeader = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_ADDRESSING_PRODUCER_FAULT_TO, URI.class);
Source soapHeaderSource = exchange.getIn().getHeader(SpringWebserviceConstants.SPRING_WS_SOAP_HEADER, Source.class);
WebServiceMessageCallback callback = new DefaultWebserviceMessageCallback(soapActionHeader, wsAddressingActionHeader, wsReplyToHeader, wsFaultToHeader, soapHeaderSource, getEndpoint().getConfiguration(), exchange);
if (endpointUriHeader == null) {
endpointUriHeader = getEndpoint().getConfiguration().getWebServiceTemplate().getDefaultUri();
}
getEndpoint().getConfiguration().getWebServiceTemplate().sendAndReceive(endpointUriHeader, new WebServiceMessageCallback() {
@Override
public void doWithMessage(WebServiceMessage requestMessage) throws IOException, TransformerException {
XML_CONVERTER.toResult(sourcePayload, requestMessage.getPayloadResult());
callback.doWithMessage(requestMessage);
}
}, new WebServiceMessageCallback() {
@Override
public void doWithMessage(WebServiceMessage responseMessage) throws IOException, TransformerException {
SoapMessage soapMessage = (SoapMessage) responseMessage;
if (ExchangeHelper.isOutCapable(exchange)) {
exchange.getOut().copyFromWithNewBody(exchange.getIn(), soapMessage.getPayloadSource());
populateHeaderAndAttachmentsFromResponse(exchange.getOut(), soapMessage);
} else {
exchange.getIn().setBody(soapMessage.getPayloadSource());
populateHeaderAndAttachmentsFromResponse(exchange.getIn(), soapMessage);
}
}
});
}
use of org.springframework.ws.client.core.WebServiceMessageCallback in project spring-integration by spring-projects.
the class WebServiceOutboundGatewayParserTests method simpleGatewayWithCustomRequestCallback.
@Test
public void simpleGatewayWithCustomRequestCallback() {
AbstractEndpoint endpoint = this.context.getBean("gatewayWithCustomRequestCallback", AbstractEndpoint.class);
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
}
Aggregations