how to make my controller accept XML body?

hey guys. i have this controller:
GetMapping(value = "/transactions", produces = "application/xml")
public String getCurrentTransactions() throws JAXBException, IOException {
return bgwService.getCurrentTransactions();
}
GetMapping(value = "/transactions", produces = "application/xml")
public String getCurrentTransactions() throws JAXBException, IOException {
return bgwService.getCurrentTransactions();
}
and in my service i have hardcoded small XML. and i want to be able to accept XML and ditch the hardcoded XML in my service. can i use some kind of annotation in my controller? how to aproach it? thanks alot.
8 Replies
JavaBot
JavaBot6mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st6mo ago
Stack Overflow
How can Spring RestController accept both JSON and XML?
I have a Spring controller that works great: @RestController @RequestMapping(value = "/widgets") class WidgetController { @RequestMapping(method = RequestMethod.POST) WidgetResponse create...
dan1st
dan1st6mo ago
Baeldung
Using XML in @RequestBody in Spring REST | Baeldung
Learn how to leverage Jackson XML to use XML within Spring REST.
bambyzas
bambyzasOP6mo ago
i thought there were other alternatives too. i knew about this thanks. ill just use it and wont bother with anything
JavaBot
JavaBot6mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts. Before your post will be closed, would you like to express your gratitude to any of the people who helped you? When you're done, click I'm done here. Close this post!.
dan1st
dan1st6mo ago
I mean, you can also use other XML parsing mechanisms
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot6mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server