Skip to content

XML request body cannot be deserialised by Spring web 5 with javax.xml.bind.annotation #25273

Closed
@quancheng-zhao

Description

@quancheng-zhao

Hello, when upgrading SpringBoot from 1.x to 2.x, Restful apis which consumes xml as request body are broken because values are deserialised to null.

API is like:

@RequestMapping(
            method = POST,
            consumes = {APPLICATION_XML_VALUE, TEXT_XML_VALUE},
            produces = {APPLICATION_XML_VALUE, TEXT_XML_VALUE})
    Response postSomething(@ApiParam(name = "Request", value="A valid <Request /> xml query") @Valid @RequestBody **XmlRequest** xmlRequest);

XmlRequest used javax.xml.bind.annotation. Then I changed annotation to jackson-dataformat-xml, request body can be deserialised as before.

I don't find any report about javax xml problem. Does SpringBoot 2 have some limitation to use this package? Should XML deserialisation use jackson xml databinding? When I refactored the code, I find out jackson xml databing has less annotation and it works not well with polymorphic subtypes.

Thanks for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions