好吧,我到處搜索了一個答案。這讓我瘋狂。在不使用@XMLRootElement註釋的情況下解組一個REST響應
我只需要解組一個非常簡單的webservice響應。唯一的問題是,我正在使用不帶@XmlRootElement
註釋的生成源文件。我無法編輯這個生成的源文件來添加@XmlRootElement
。我需要「按原樣」使用它。
這是我有的當前代碼,但它導致在這篇文章底部顯示的錯誤。我試圖使用JAXBElement
包裝,但無濟於事。有人可以給我我需要的代碼嗎?我不知道如何使用"QName"s
等
下面這段代碼有@XmlRootElement
類的偉大工程:
MyGeneratedClass response = restTemplate.getForObject("url to webservice!"),
MyGeneratedClass.class);
return response
可悲的是,它是生產在這種情況下,這個錯誤。請幫我解開REST響應!
Could not extract response: no suitable HttpMessageConverter found for response
type [MyGeneratedClass] and content type [application/xml;version=1]