Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do unmarshalling to different objects depending on the XML received?
    primarykey
    data
    text
    <p>I have a web service which receives XML files and does unmarshalling to convert the XML file to an object. The problem is that my web service can receive different XML structures and has to do the correct unmarshalling.</p> <p>So I receibe this kind of XML files:</p> <pre><code>&lt;root&gt; &lt;user&gt; &lt;id&gt;1234&lt;/id&gt; &lt;/user&gt; &lt;XMLelements&gt; ... &lt;/XMLelements&gt; &lt;/root&gt; </code></pre> <p>Notice that <code>XMLelements</code> is an example tag name, every XML file could have differents names.</p> <p>So, I think, my web service workflow should be something like:</p> <ol> <li>It receives XML file.</li> <li>It checks user id. <ul> <li>If user id == 1234 <ul> <li>UserA userA = unmarshalling(XMLFile)</li> </ul></li> <li>Else if user id == 5678 <ul> <li>UserB userB = unmarshalling(XMLFile)</li> </ul></li> <li>Else <ul> <li>UserC userC = unmarshalling(XMLFile)</li> </ul></li> </ul></li> </ol> <p>So I receive different XML structures and for each one I have to do a different unmarshalling to get objects of different classes.</p> <p>How can I perform this approach? I'm using Spring for marshalling (Metro).</p> <p><strong>Edit:</strong> This question didn't receive any answer, maybe I'm not clear. I'll try to explain it better:</p> <p>I have a web service which is listening a url where receives XML files. Actually, in the same url path my web service receives two different XML schemas. How can I know how to do unmarshalling correctly? I mean, unmarshalling should return correct object when different XML schemas are passed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload