gungor / spring-webclient-soap

38 stars 24 forks source link

Could not unmarshal XML to class when using Spring Cloud Hoxton.SR8 #2

Closed mariusgiger closed 3 years ago

mariusgiger commented 3 years ago

Hi @gungor, first of all thanks a lot for the example and your blog post! I am trying to replicate this case to a similar scenario, however, I am facing the issue that the soap envelope is not properly handled when decoding the response and therefore the processing fails:

org.springframework.core.codec.DecodingException: Could not unmarshal XML to class io.spring.guides.gs_producing_web_service.GetCountryResponse; nested exception is javax.xml.bind.UnmarshalException
 - with linked exception:
[com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 79; unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/", local:"Envelope"). Expected elements are <{http://spring.io/guides/gs-producing-web-service}getCountryResponse>]

    at org.springframework.http.codec.xml.Jaxb2XmlDecoder.unmarshal(Jaxb2XmlDecoder.java:222)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Error has been observed at the following site(s):
    |_ checkpoint ⇢ Body from POST http://localhost:8081/ws [DefaultClientResponse]
Stack trace:

I am wondering if you faced similar issues at some point?

This happens when running with a with Spring Cloud Hoxton.SR8. It can replicated by replacing the parent by the following in pom.xml:

    <parent>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-parent</artifactId>
        <version>Hoxton.SR8</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

Cheers, marius

gungor commented 3 years ago

Hi Marius,

This problem is caused by different versions of jaxb-runtime. I will add Jaxb2SoapDecoder soon.

gungor commented 3 years ago

Jaxb2SoapDecoder added, now it works with Spring Cloud Hoxton.SR8

mariusgiger commented 3 years ago

great, this works! thanks a lot @gungor!