• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@RequestBody unable to bind to XStream POJO.

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trying to post an xml data to spring rest api as given below:

@RequestMapping(value = "/views/store",method=RequestMethod.POST)
@XmlMimeType(value="application/xml")
public View addStore(@RequestBody StoreVO store){
System.out.println(store.getName());
}

StoreVO
@XStreamAlias("store")
public class StoreVO{
}

Request body is unable to bind it to value object, but its able to bind it to String.

Any quick help is appreciated.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you registered the HttpMessageConverter for XStream to your ContextNegotiatingViewResolver? You might also need to register a marshaller and unmarshaller.

Mark
 
Shriram Gopalakrishnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark, this is how i have configured my marshaller. Is there anything missing thats needs to be added?

 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a Code button above to keep your code indented. Posting without it makes it difficult to read.

Where is your configuration for your ContentNegotiatingViewResolver?

Thanks

Mark
 
Shriram Gopalakrishnan
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Mark, I had pasted the code in hurry but have corrected it now. So to answer your question I have not used ContentNegotiatingViewResolver since with above configuration i was able to receive XML output for an spring rest api but faced issues while trying to post xml data. In other words can you let me know the lines to inject in above config related to ContentNegotiatingViewResolver to resolve the issue

Thanks!
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shriram Gopalakrishnan wrote:Sorry Mark, I had pasted the code in hurry but have corrected it now. So to answer your question I have not used ContentNegotiatingViewResolver since with above configuration i was able to receive XML output for an spring rest api but faced issues while trying to post xml data. In other words can you let me know the lines to inject in above config related to ContentNegotiatingViewResolver to resolve the issue

Thanks!



Unfortunately, I can only point you to the Spring Framework documentation. There is a whole section on the ContentNegotiatingViewResolver.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic