use of org.springframework.ws.client.core.WebServiceTemplate in project camel by apache.
the class SpringWebserviceComponent method configureProducerConfiguration.
private void configureProducerConfiguration(String remaining, SpringWebserviceConfiguration configuration) throws URISyntaxException {
if (configuration.getEndpointMapping() == null && configuration.getEndpointDispatcher() == null) {
LOG.debug("Building Spring Web Services producer");
URI webServiceEndpointUri = new URI(UnsafeUriCharactersEncoder.encode(remaining));
// Obtain a WebServiceTemplate from the registry when specified by
// an option on the component, else create a new template with
// Spring-WS defaults
WebServiceTemplate webServiceTemplate = configuration.getWebServiceTemplate();
if (webServiceTemplate == null) {
webServiceTemplate = new WebServiceTemplate();
configuration.setWebServiceTemplate(webServiceTemplate);
}
if (webServiceTemplate.getDefaultUri() == null) {
String uri = webServiceEndpointUri.toString();
webServiceTemplate.setDefaultUri(uri);
configuration.setWebServiceEndpointUri(uri);
}
if (configuration.getMessageSender() != null) {
webServiceTemplate.setMessageSender(configuration.getMessageSender());
}
if (configuration.getMessageFactory() != null) {
webServiceTemplate.setMessageFactory(configuration.getMessageFactory());
}
}
}
use of org.springframework.ws.client.core.WebServiceTemplate in project camel by apache.
the class AbstractWSATests method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
// initialize beans for catching results
webServiceTemplate = applicationContext.getBean("webServiceTemplate", WebServiceTemplate.class);
newReply = getMandatoryBean(OutputChannelReceiver.class, "replyReceiver");
response = getMandatoryBean(OutputChannelReceiver.class, "responseReceiver");
// sample data
source = new StreamSource(new StringReader(xmlBody));
result = new StreamResult(new StringWriter());
// reset from previous test
response.clear();
newReply.clear();
requestInputAction = null;
}
use of org.springframework.ws.client.core.WebServiceTemplate in project spring-integration by spring-projects.
the class WebServiceOutboundGatewayParserTests method jmsUri.
@Test
@SuppressWarnings("unchecked")
public void jmsUri() {
AbstractEndpoint endpoint = this.context.getBean("gatewayWithJmsUri", AbstractEndpoint.class);
assertEquals(EventDrivenConsumer.class, endpoint.getClass());
MessageHandler handler = TestUtils.getPropertyValue(endpoint, "handler", MessageHandler.class);
assertNull(TestUtils.getPropertyValue(handler, "destinationProvider"));
assertFalse(TestUtils.getPropertyValue(handler, "encodeUri", Boolean.class));
WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(handler, "webServiceTemplate", WebServiceTemplate.class);
webServiceTemplate = spy(webServiceTemplate);
doReturn(null).when(webServiceTemplate).sendAndReceive(anyString(), any(WebServiceMessageCallback.class), ArgumentMatchers.<WebServiceMessageExtractor<Object>>any());
new DirectFieldAccessor(handler).setPropertyValue("webServiceTemplate", webServiceTemplate);
handler.handleMessage(new GenericMessage<String>("foo"));
verify(webServiceTemplate).sendAndReceive(eq("jms:wsQueue"), any(WebServiceMessageCallback.class), ArgumentMatchers.<WebServiceMessageExtractor<Object>>any());
}
use of org.springframework.ws.client.core.WebServiceTemplate in project spring-integration by spring-projects.
the class UriVariableTests method testHttpUriVariables.
@Test
@SuppressWarnings("unchecked")
public void testHttpUriVariables() {
WebServiceTemplate webServiceTemplate = TestUtils.getPropertyValue(this.httpOutboundGateway, "webServiceTemplate", WebServiceTemplate.class);
webServiceTemplate = Mockito.spy(webServiceTemplate);
final AtomicReference<String> uri = new AtomicReference<>();
doAnswer(invocation -> {
uri.set(invocation.getArgument(0));
throw new WebServiceIOException("intentional");
}).when(webServiceTemplate).sendAndReceive(Mockito.anyString(), Mockito.any(WebServiceMessageCallback.class), (WebServiceMessageExtractor<Object>) Mockito.any(WebServiceMessageExtractor.class));
new DirectFieldAccessor(this.httpOutboundGateway).setPropertyValue("webServiceTemplate", webServiceTemplate);
Message<?> message = MessageBuilder.withPayload("<spring/>").setHeader("x", "integration").setHeader("param", "test1 & test2").build();
try {
this.inputHttp.send(message);
} catch (MessageHandlingException e) {
// expected
// offline
assertThat(e.getCause(), Matchers.is(Matchers.instanceOf(WebServiceIOException.class)));
}
assertEquals("http://localhost/spring-integration?param=test1%20&%20test2", uri.get());
}
use of org.springframework.ws.client.core.WebServiceTemplate in project spring-boot by spring-projects.
the class WebServiceTemplateBuilderTests method additionalCustomizersShouldAddToExisting.
@Test
void additionalCustomizersShouldAddToExisting() {
WebServiceTemplateCustomizer customizer1 = mock(WebServiceTemplateCustomizer.class);
WebServiceTemplateCustomizer customizer2 = mock(WebServiceTemplateCustomizer.class);
WebServiceTemplate template = this.builder.customizers(customizer1).additionalCustomizers(customizer2).build();
then(customizer1).should().customize(template);
then(customizer2).should().customize(template);
}
Aggregations