Re: framework for marsheling java beans to xml accroding to xml Schema?
- From: elh.maayan@xxxxxxxxx
- Date: Tue, 6 Jan 2009 09:47:29 -0800 (PST)
On Jan 6, 6:17 pm, JC <jason.cipri...@xxxxxxxxx> wrote:
On Jan 6, 8:37 am, elh.maa...@xxxxxxxxx wrote:
hi..
is there a framework, that given a java bean and an xml schema from a
wsdl, would be able to marhsall it correctly according to that schema?
( i need to convert it later to an OMElement of axis)
An XML schema imposes constraints on the contents of an XML document
but does not define a mapping of arbitrary data to that XML. There is
not enough info in an XML schema to map a bean to XML. Some XML
element names may coincidentally have the same names as some of your
bean fields but that is not sufficient information for a mapping.
One option is to use java.beans.XMLEncoder (http://java.sun.com/j2se/
1.4.2/docs/api/java/beans/XMLEncoder.html) to serialize your bean to
XML. I have never used XMLEncoder. AFAIK, your bean will have to mimic
the correct XML schema so that the generated XML conforms to it.
Another option is to use something like XStream (http://
xstream.codehaus.org/, very easy to use) to serialize your object into
XML. XStream will let you define the mappings. Make sure the mappings
from fields -> XML elements that you define conform to your schema,
and you will be good to go. XStream, however, does not operate on bean
fields, it operates directly on member fields (you can define mappings
with annotations).
There may be more appropriate solutions, those are the only two I can
think of, though.
Jason
we are allready using XStream, however i need something that will
conform to XSD in wsdl, meaning if i feed a wsdl, it will not that
some attributes should be qualifed with a namespace, and some not, we
allready have classes previosyl generated accroding the schema,but the
tool that generated them (glue) is about to be replaced with axis, so
i'm not afraid about mapping, but with names space issues.
.
- References:
- Prev by Date: Re: speeding up javac
- Next by Date: Re: speeding up javac
- Previous by thread: Re: framework for marsheling java beans to xml accroding to xml Schema?
- Next by thread: Re: framework for marsheling java beans to xml accroding to xml Schema?
- Index(es):
Relevant Pages
|