Announcement Announcement Module
No announcement yet.
Suggestions for handling XML requests with generic field names? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Suggestions for handling XML requests with generic field names?

    I'm developing a Spring 3 MVC app and I need to handle HTTP POST requests with XML in the following format:

    <?xml version="1.0" encoding="UTF-8"?>
    		<Field_002>some value</Field_002>
    		<Field_003>some value</Field_003>
    		<Field_004>some value</Field_004>
    		<Field_005>some value</Field_005>
    There can be ~100 fields, all named Field_nnn. The actual fields included in a request will vary depending on the message type.

    I've previously used XStream with @RequestBody/@ResponseBody for more consistently-structured XML requests, but I'd rather not map this XML structure onto a class with so many fields. Ideally I'd like to map it to an object with a list of general fields, and implement setField(index, value)/GetField(index) methods, having it serialize/deserialize depending on which fields are present.

    Are there any Spring-friendly mapping frameworks that can accommodate this? Am I better off handling SAX events myself for this? All suggestions/thoughts welcome!