SOAP client configuration No marshaller registered

171 views Asked by At

I'm trying to consume a SOAP service with spring boot and kotlin. But my application doesn´t recognize a marshaller within the service(client).

The project compiles and runs, but when I make the request to the endpoint "/get", i have the error:

java.lang.IllegalStateException: No marshaller registered. Check configuration of WebServiceTemplate.

I made this client:

class ExtraccionCatalogosService: WebServiceGatewaySupport() {


    fun extraer(){
        println("Iniciando extracción de catálogos")
        val request = VehiculoMarca()
        request.proveedor = "XXXXX"
        request.password = "XXXX"
        request.usuario = "AH"
        request.token = "00000000000"
        request.tipoVehiculo = "01"
        request.negocio = ""
        val response = WebServiceTemplate().marshalSendAndReceive("https://pruebas.seguros.com/webservices/cot?wsdl", request, SoapActionCallback("http://ws.units.seguros.com/")) as VehiculoMarcaResponse
        println(response)
    }
}

And added this configuration, I already generated the models in the path "com.ws.seguros.models.wsdl", inside my src/main/kotlin package.

@Configuration
class ExtraccionMarshaller {

    @Bean
    fun getMarshaller(): Jaxb2Marshaller{
        println("configurando marshaller")
        val jaxb2Marshaller = Jaxb2Marshaller()
        jaxb2Marshaller.contextPath = "com.ws.seguros.models.wsdl"
        return jaxb2Marshaller
    }

    @Bean
    fun getExtraccionCatalogos(jaxb2Marshaller: Jaxb2Marshaller): ExtraccionCatalogosService{
        println("configuracndo extraccion service")
        val extraccionCatalogosService = ExtraccionCatalogosService()
        extraccionCatalogosService.defaultUri = "https://pruebas.seguros.com/webservices/cot?wsdl"
        extraccionCatalogosService.marshaller = jaxb2Marshaller
        extraccionCatalogosService.unmarshaller = jaxb2Marshaller
        return extraccionCatalogosService
    }
}

Finally, I have this controller:

@RestController
class ExtraccionCatalogosController {

    @Autowired
    lateinit var extraccionCatalogosService: ExtraccionCatalogosService

    @GetMapping("/get")
    fun extraer(){
        val resp = extraccionCatalogosService.extraer()
        println(resp)

    }
}
1

There are 1 answers

0
Adonis Becerra Morales On

I found the answer. As I was using Kotlin, the IDE recommended using WebServiceTemplate() in the service(client), but this was affecting the one already created in the bean. When I changed it to getWebServiceTemplate() it started working.