Castor Problem

F

Fenice

Hi all,

I'm using Castor to bind an XML document starting from an XML Schema.
All is working fine and normally I haven't any problem.
I'm using an XML Schema do describe this XML:

<MCMJ_RESULTS>
<ERROR_CODE>0000</ERROR_CODE>
<ERROR_MESSAGE>Pin updated</ERROR_MESSAGE>
</MCMJ_RESULTS>

Now I would like to fill my class also if I receive an XML like:

<MCMJ_RESULTS>
<ERROR_CODE>0000</ERROR_CODE>
<ERROR_MESSAGE>Pin updated</ERROR_MESSAGE>
<Test>Adds</Test>
</MCMJ_RESULTS>

I wrote Test but is possible that I receive Test1, or Object, or
something else and is also possible that I receive more other nodes.
To load my XML I'm using this:

list = (MCMJ_RESULTS)MCMJ_RESULTS.unmarshal(new StringReader(sw));

In this case it's normal that I cannot to validate the XML but I would
like to be able to read ERROR_CODE and ERROR_MESSAGE using:

ris=list.getERROR_CODE();

Now my code is not working because after the unmarshal I'm receiving
list=null.
If I didn't be cleare please ask me more detail.



Someone can help me to solve this problem?


Thank you.
 
F

Fenice

Someone can help me to solve this problem?

I solved my problem :)

MCMJRESULTS lista=null;


Unmarshaller unmar = new Unmarshaller(MCMJ_RESULTS.class);
unmar.setIgnoreExtraElements(true);
unmar.setIgnoreExtraAttributes(true);
unmar.setValidation(false);

try
{
list = (MCMJ_RESULTS)unmar.unmarshal(new StringReader(sw));

}
catch (ValidationException ex)
{
logger.warn("Errore Validazione WebService UpdatePin:
"+ex.getMessage());
}
catch (MarshalException ex)
{
logger.warn("Errore WebService UpdatePin: "+ex.getMessage());
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top