Retornando elementos gerados por JAXB do Spring Boot Controller

Estou gerando uma infinidade de arquivos Java dehttp://www.ncpdp.orgarquivos XSD (disponíveis apenas para membros). Depois de gerá-los, gostaria de usá-los nos meus Spring Controllers, mas estou tendo problemas para obter respostas convertidas em XML.

Eu tentei retornar o próprio elemento, bem como JAXBElement <T>, mas nenhum deles parece funcionar. O teste abaixo falha:

java.lang.AssertionError: Status 
Expected :200
Actual   :406

@Test
public void testHelloWorld() throws Exception {
    mockMvc.perform(get("/api/message")
            .accept(MediaType.APPLICATION_XML)
            .contentType(MediaType.APPLICATION_XML))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_XML));
}

Aqui está o meu controlador:

import org.ncpdp.schema.transport.MessageType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {

    @RequestMapping(value = "/api/message", method = RequestMethod.GET)
    public MessageType messageType() {
        return new MessageType();
    }
}

Tentei criar um MvcConfig para substituir a configuração MVC do Spring Boot, mas ele não parece estar funcionando.

@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        converters.add(marshallingHttpMessageConverter());
    }

    @Bean
    public MarshallingHttpMessageConverter marshallingHttpMessageConverter() {
        Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
        jaxb2Marshaller.setPackagesToScan(new String[]{"com.ncpdb.schema.transport"});

        MarshallingHttpMessageConverter converter = new MarshallingHttpMessageConverter();
        converter.setMarshaller(jaxb2Marshaller);
        converter.setUnmarshaller(jaxb2Marshaller);
        converter.setSupportedMediaTypes(Arrays.asList(MediaType.APPLICATION_XML));

        return converter;
    }
}

O que preciso fazer para que o Spring MVC marshall meus objetos JAXB gerados como XML?

questionAnswers(1)

yourAnswerToTheQuestion