Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Castor Problem

Thread view: 
Fenice - 20 Nov 2006 16:52 GMT
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.
Fenice - 21 Nov 2006 08:16 GMT
> 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());
        }


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.