You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Florent Georges <da...@yahoo.fr> on 2007/06/06 12:30:52 UTC
Instanciate Java classes from XML instances (classes from wsdl2java)
Hi
I looked in the archives for an answer to my problem, but
I didn't find anything. Actually I saw several similar
questions but they were never answered.
I have generated binding classes with wsdl2java. For
tests, I have XML documents on the file system, and I'd like
to get the corresponding Java objects (instances of the
classes generated by wsdl2java).
I guess that would be easy with Axis, but I didn't find
the way to go. I use Axis 1.4.
Thanks in advance. Regards,
--drkm
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org
RE: Instanciate Java classes from XML instances (classes from wsdl2java)
Posted by "Kraus, David" <dk...@MicroStrategy.com>.
XMLReader's parse method accepts a string URI, so your file
specification is wrong.
Should be something like:
reader.parse("file:///home/colo/PlatformCatalogue.xml");
________________________________
From: Adrian Colomitchi [mailto:acolomitchi@gmail.com]
Sent: Wednesday, June 06, 2007 4:56 AM
To: axis-user@ws.apache.org
Subject: Re: Instanciate Java classes from XML instances (classes from
wsdl2java)
I'm battling with the same problem for some time now (like 3-4 hours).
Assuming PlatformCatalogue is a class generated by AXIS, I'm circling
the following piece of code (on the idea that BeanDeserializer is a
org.xml.sax.helpers.DefaultHandler):
TypeDesc plCatTypeDesc=PlatformCatalogue.getTypeDesc();
BeanDeserializer deserializer=
new BeanDeserializer(PlatformCatalogue.class,
plCatTypeDesc.getXmlType(), plCatTypeDesc);
XMLReader reader;
try {
reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(deserializer);
reader.setErrorHandler(deserializer);
reader.setEntityResolver(deserializer);
reader.setDTDHandler(deserializer);
reader.parse("/home/colo/PlatformCatalogue.xml");
PlatformCatalogue
toUse=(PlatformCatalogue)deserializer.getValue();
} catch (SAXException e) {
e.printStackTrace();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
Now, I my mind, the above should work, but in reality it doesn't!!
No exception thrown, however the loaded PlatformCatalogue instance is
empty (no inner elements are created/set). What's wrong with it? I swear
the XML file does have a valid and non-empty content for the root tag.
It drives my crazy, I'll end totaly bald!! Someone, please help!
Best regards and thanks in advance,
Adrian
Florent Georges wrote:
Hi
I looked in the archives for an answer to my problem, but I
didn't find anything. Actually I saw several similar questions but they
were never answered.
I have generated binding classes with wsdl2java. For tests, I
have XML documents on the file system, and I'd like to get the
corresponding Java objects (instances of the classes generated by
wsdl2java).
I guess that would be easy with Axis, but I didn't find the way
to go. I use Axis 1.4.
________________________________
View this message in context: Re: Instanciate Java classes from XML
instances (classes from wsdl2java)
<http://www.nabble.com/Instanciate-Java-classes-from-XML-instances-%28cl
asses-from-wsdl2java%29-tf3877102.html#a10987143>
Sent from the Axis - User mailing list archive
<http://www.nabble.com/Axis---User-f232.html> at Nabble.com.
Re: Instanciate Java classes from XML instances (classes from
wsdl2java)
Posted by Adrian Colomitchi <ac...@gmail.com>.
I'm battling with the same problem for some time now (like 3-4 hours).
Assuming PlatformCatalogue is a class generated by AXIS, I'm circling the
following piece of code (on the idea that BeanDeserializer is a
org.xml.sax.helpers.DefaultHandler):
TypeDesc plCatTypeDesc=PlatformCatalogue.getTypeDesc();
BeanDeserializer deserializer=
new BeanDeserializer(PlatformCatalogue.class, plCatTypeDesc.getXmlType(),
plCatTypeDesc);
XMLReader reader;
try {
reader = XMLReaderFactory.createXMLReader();
reader.setContentHandler(deserializer);
reader.setErrorHandler(deserializer);
reader.setEntityResolver(deserializer);
reader.setDTDHandler(deserializer);
reader.parse("/home/colo/PlatformCatalogue.xml");
PlatformCatalogue toUse=(PlatformCatalogue)deserializer.getValue();
} catch (SAXException e) {
e.printStackTrace();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
Now, I my mind, the above should work, but in reality it doesn't!!
No exception thrown, however the loaded PlatformCatalogue instance is empty
(no inner elements are created/set). What's wrong with it? I swear the XML
file does have a valid and non-empty content for the root tag.
It drives my crazy, I'll end totaly bald!! Someone, please help!
Best regards and thanks in advance,
Adrian
Florent Georges wrote:
>
> Hi
>
>
I looked in the archives for an answer to my problem, but
> I didn't find anything. Actually I saw several similar
> questions but they were never answered.
>
>
I have generated binding classes with wsdl2java. For
> tests, I have XML documents on the file system, and I'd like
> to get the corresponding Java objects (instances of the
> classes generated by wsdl2java).
>
>
I guess that would be easy with Axis, but I didn't find
> the way to go. I use Axis 1.4.
>
--
View this message in context: http://www.nabble.com/Instanciate-Java-classes-from-XML-instances-%28classes-from-wsdl2java%29-tf3877102.html#a10987143
Sent from the Axis - User mailing list archive at Nabble.com.