The wsdl2java produces a class with the same problem. I did just
discover though if I put the following tag on the class, I can get it to
work.
@XmlAccessorType(XmlAccessType.NONE)
Any value for the XmlAccessType other than NONE has the problem, but
with NONE it works. It means I have to annotate everything rather than
letting public field/accessors determine things, but it does work :)
As for the bug location, sorry about that. CXF is a black box to me
still and I'm not sure yet where it stops and underlying 3rd party
functionality begins.
Thanks,
Chris
-----Original Message-----
From: Daniel Kulp [mailto:[email protected]]
Sent: Friday, November 13, 2009 11:54 AM
To: [email protected]
Cc: Kessel, Christopher
Subject: Re: @XmlValue complaining about non existent @XmlElement
Well, it's probably not a CXF bug as we pretty much just delegate all
that
stuff down to the JAXB runtime.
My suggestion is to write a schema for what you WANT it to look like and
run
the JAXB schema compiler on it and see what it produces.
Dan
On Fri November 13 2009 1:39:15 pm Kessel, Christopher wrote:
> That works, but doesn't solve my problem. My input is:
>
> <contact>Jim</contact> // actually, it would have some
> attributes, but I'm just trying the simplest case right now
>
> The annotations you mentioned produce XML like so.
> <contact><name>Jim</name></contact>
>
> The problem is there appears to be a bug in CXF when I publish the
> endpoint where a mapped object has the @XmlValue annotation.
Everything
> I can find says that's the correct way to indicate the XML should be
> read/written in the format I'm looking for, but CXF gives the error
when
> I actually try to use Endpoint.publish() to start the server listening
> for requests.
>
> I've tried with and without XmlRootElement definitions, XmlType with
> propOrder, all sorts of things that various examples seem to indicate
> might help, but nothing works. Maybe I'm missing something, but it
sure
> looks like a bug.
>
> If a class has @XmlElement property, it cannot have @XmlValue
> property.
> this problem is related to the following location:
> at private java.lang.String
> com.transunion.cis.iq411.soap.C360Contact._name
> at com.transunion.cis.iq411.soap.C360Contact
> at public
> com.transunion.cis.iq411.soap.C360Contact
>
> Chris
>
> -----Original Message-----
> From: Tomas Majak [mailto:[email protected]]
> Sent: Friday, November 13, 2009 12:11 AM
> To: [email protected]
> Cc: Kessel, Christopher
> Subject: RE: @XmlValue complaining about non existent @XmlElement
>
> What about using:
> @XmlElement(name = "name")
> private String _name;
>
> And class annotation:
> @XmlRootElement(name = "contact")
> @XmlAccessorType(value = XmlAccessType.NONE)
> public class C360Contact {
>
> -----Original Message-----
> From: Kessel, Christopher [mailto:[email protected]]
> Sent: den 12 november 2009 19:29
> To: [email protected]
> Subject: @XmlValue complaining about non existent @XmlElement
>
> I've got a really simple data class.
> public class C360Contact
> {
> @XmlValue
> private String _name;
> public String getName()
> {
> return _name;
> }
>
> public void setName( String name )
> {
> _name = name;
> }
> }
>
> I'm trying to indicate the value for the "name" attribute is in the
> content of the tag rather than a tag on its own. E.g.
>
> <contact>Jim</contact>
>
> vs.
> <contact>
> <name>Jim</name>
> </contact>
>
> However, I get the following error when publishing the endpoint. Any
> idea why?
>
> Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
> counts of IllegalAnnotationExceptions
> If a class has @XmlElement property, it cannot have @XmlValue
property.
> this problem is related to the following location:
> at private java.lang.String
> com.transunion.cis.iq411.soap.C360Contact._name
> at com.transunion.cis.iq411.soap.C360Contact
> at public com.transunion.cis.iq411.soap.C360Contact
> com.transunion.cis.iq411.soap.C360Request.getContact()
> at com.transunion.cis.iq411.soap.C360Request
> this problem is related to the following location:
> at public java.lang.String
> com.transunion.cis.iq411.soap.C360Contact.getName()
> at com.transunion.cis.iq411.soap.C360Contact
> at public com.transunion.cis.iq411.soap.C360Contact
> com.transunion.cis.iq411.soap.C360Request.getContact()
> at com.transunion.cis.iq411.soap.C360Request
>
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog