I using spring-boot-starter-parent:2.7.7
I have the below config of webclient to call soap web services
@Bean
fun webClientXml(): WebClient {
val httpClient = HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 100000).doOnConnected {
it.addHandlerLast(ReadTimeoutHandler(100))
it.addHandlerLast(WriteTimeoutHandler(100))
}.resolver(DefaultAddressResolverGroup.INSTANCE)
val exchangeStrategies = ExchangeStrategies.builder().codecs {
it.defaultCodecs().maxInMemorySize(16 * 1024 * 1024)
it.customCodecs().register(Jaxb2SoapEncoder())
it.customCodecs().register(Jaxb2SoapDecoder())
}.build()
return WebClient.builder()
.codecs { it.defaultCodecs().maxInMemorySize(16 * 1024 * 1024) }
.clientConnector(ReactorClientHttpConnector(httpClient))
.exchangeStrategies(exchangeStrategies).build()
}
application.yml
spring:
elasticsearch:
webclient:
max-in-memory-size: 512MB
codec:
max-in-memory-size: 512MB
config of Jaxb2SoapDecoder
class Jaxb2SoapDecoder : Jaxb2XmlDecoder() {
override fun setMaxInMemorySize(byteCount: Int) {
super.setMaxInMemorySize(16 * 1024 * 1024)
}
@Throws(DecodingException::class)
override fun decode(dataBuffer: DataBuffer, targetType: ResolvableType, @Nullable mimeType: MimeType?, @Nullable hints: MutableMap<String, Any>?): Any {
.....
}
}
config of Jaxb2SoapEncoder
class Jaxb2SoapEncoder : Encoder<Any> {
private fun encode(value: Any, bufferFactory: DataBufferFactory): Flux<DataBuffer> {
return Mono.fromCallable {
var release = true
val buffer = bufferFactory.allocateBuffer(1000000000)
.....
}.flux()
} }
when i invoke an api, i have the below error
org.springframework.web.reactive.function.client.WebClientResponseException: 200 OK from POST xxxxxxxxx; nested exception is org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144