-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support @XmlSeeAlso in Jaxb2XmlDecoder #30167
Comments
The The block of XML seems to represent a |
Are you saying that using the And if so how to deal with APIs like the one described that return either a Looking at
|
I did not say anything about feasibility; I said that the WebClient needs to know the specific type to unmarshal to. In this case, that's
Comparing between the blocking, synchronous RestTemplate and the reactive WebClient is really an apples and oranges comparison, as they have very different design considerations. In this case, the difference is that the <root>
<child>foo</child>
<child>bar</child>
</root> the (Note that the JDK itself has no asynchronous XML capabilities, but if you put Aalto on the classpath, we will use that to create the stream asynchronously). The
What I meant was: does I can see that single endpoints that can produce two different kinds of XML don't work well the the behavior described above. However, in my personal experience these endpoints are relatively uncommon, and—more importantly—I don't see any way for us to support those, given the aforementioned streaming requirements. |
Over the weekend I thought of a way to support |
This commit adds support for the @XmlSeeAlso annotation in the Jaxb2XmlDecoder. This includes - Finding the set of possible qualified names given a class name, rather than a single name. - Splitting the XMLEvent stream when coming across one of the names in this set. Closes spring-projectsgh-30167
While introducing WebClient into my current project I ran into the issue that the call
causes the error
We have the following simplified class hierarchy:
One possible response body to be decoded is
Assumed that there is nothing really wrong with the given simplified example
the unmarshal seems to be the issue.
Since
RealEstate
is not annotated asXmlRootElement
the else block is executed which causes the error.Using the other method without handing over the target class would work.
I cannot say if the
Unmarshaller#unmarshal(XMLEventReader reader, Class<T> declaredType )
method is supposed to work when usingXMLSeeAlso
as described in the simplified example.Looking into how the
RestTemplate
solved the task it boils down to theMarshallingHttpMessageConverter
doingIt seems that the
Jaxb2XmlDecoder
differentiates for some reason while theMarshallingHttpMessageConverter
is doing the type check after unmarshalling.Also asked at stackoverflow without getting any response.
The text was updated successfully, but these errors were encountered: