-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Description
Hi,
Jackson-xml marshalling seems to be broken in the 2.0.0 M2 milestone release for Spring boot (with web-flux). I tried both with functional web routers and a 'classic' (simple) annotation based controller (kotlin):
data class Hello(val one: String, val two: String)
@Bean
fun apiRouter() = router {
GET("/hello") { req ->
ok().contentType(MediaType.APPLICATION_XML)
.body(BodyInserters.fromObject(Hello("Hello", "World")))
}
}
And
data class Hello(val one: String, val two: String)
@RestController
class HelloController {
@GetMapping("/hello") fun sayHello() = Hello("Hello", "World")
}
The jackson XML marshaller doesn't seem to be registered automatically anymore.
Steps to reproduce
- Create a Spring Boot project (start.spring.io) -> 2.0.0 M2 with the reactive web dependency;
- Add a restcontroller that returns a simple entity (see above);
- Add
jackson-dataformat-xml
dependency.
Call the endpoint with the application/xml
accept header. The sever will respond with a 406 - not acceptable
response. In the logging this shows up:
2017-06-23 12:39:42.629 ERROR 26064 --- [ctor-http-nio-2] o.s.w.s.h.ResponseStatusExceptionHandler : Response status 406 with reason "Could not find acceptable representation"
Verification
I've tried a similar approach with Spring Boot 1.5.4 and there it works as expected, depending on the provided accept header (application/xml
or application/json
) the application responds with the response in the requested format.