-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
In what version(s) of Spring Integration are you seeing this issue?
5.5.6, 5.4.x, but other versions are affected as well
Describe the bug
In MarshallingWsOutboundGatewaySpec.MarshallingWsOutboundGatewayNoTemplateSpec class the assemble() method overwrites messageSenders and faultMessageResolver's otherwise useful and valid default not null values
with null values in the WebServiceTemplate created by the builder itself if no values provided in the builder explicitly:
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/MarshallingWsOutboundGatewaySpec.java#L144
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java#L181
Also, one MUST provide an encodingMode in the builder, because BaseWsOutboundGatewaySpec does exactly the same (overwrites the correct default value without null checking) with the UriFactory's encodingMode:
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/dsl/BaseWsOutboundGatewaySpec.java#L162
https://github.com/spring-projects/spring-integration/blob/5.4.x/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceOutboundGateway.java#L140
To Reproduce
create a Ws.marshallingOutboundGateway()
Expected behavior
faultMessageResolver, messageSenders and enCodingmode:
- may be left unspecified in builder, in which case the defaults in WebServiceTemplate and UriFactory should be left intact
(Note: A simple null check before the setter calls would be sufficient.) - if one needs null values, they should provide WebServiceTemplate and UriFactory explicitly (with mentioned fields set to null)
Sample
IntegrationFlow myFlow = IntegrationFlows
.from(MessageChannels.direct("myChannel"))
.handle(
Ws.marshallingOutboundGateway()
.marshaller(jaxb2Marshaller())
.destinationProvider(createDestinationProvider(myBackendUri))
// IntegrationFlows's Ws.marshallingOutBoundGateway a little bit buggy, it
// overwrites nice defaults already set, so we have to provide encodingMode,
// faultMessageResolver and MessageSenders here, otherwise they will be nulled,
// which results in an error...
.encodingMode(DefaultUriBuilderFactory.EncodingMode.TEMPLATE_AND_VALUES)
.messageSenders(getWebserviceTemplateDefaultMessageSenders())
.faultMessageResolver(getWebserviceTemplateDefaultFaultMessageResolver()))
.get();