NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Dealing With a Schema for Which There is No xmlrootelement

 
Post new topic   Reply to topic    NetBeans Forums -> SOA Users
View previous topic :: View next topic  
Author Message
jsexton0
Posted via mailing list.





PostPosted: Wed Feb 11, 2009 8:02 pm    Post subject: Dealing With a Schema for Which There is No xmlrootelement Reply with quote

I understand why the xmlrootelement annotation is not always generated. Just
the same, I have to work with a schema for which JAXB does not (rightly)
create the @XmlRootElement. What I need to do is make a string out of the
data, then get the JAXB object back out latter.

To create the String, I added a "wrapper" like this:

marshaller.marshal(new JAXBElement(
new QName("http://mydomain/schema/MyNamesape", "MyMessage"),
MyMessageType.class, request), sw);

However, the code Netbeans creates to convert this String back to an XML
object gives me a java.lang.ClassCastException on the resulting Object.
I've confirmed that the data (String) is intact, and is what I expect.

Is there a general approach to making a JAXB object with no @XmlRootElement
pass through conversion to a String and back again?

Thanks
Thanks
--
View this message in context: http://www.nabble.com/Dealing-With-a-Schema-for-Which-There-is-No-xmlrootelement-tp21963039p21963039.html
Sent from the NetBeans - EntPack mailing list archive at Nabble.com.
Back to top
jsexton0
Posted via mailing list.





PostPosted: Wed Feb 11, 2009 8:59 pm    Post subject: Dealing With a Schema for Which There is No xmlrootelement Reply with quote

Sorry for answering my own post, but maybe this will help someone else. I
don't know why I so frequently figure out something just after posting some
place like this...

If I unmarshal to a JAXBElement instead of the type I'm looking for, then
the JAXBElement's getValue() result can be cast to the complex type I
started with and everyone is happy. This makes perfect sense now that I see
it.

Thanks again


jsexton0 wrote:
Quote:

I understand why the xmlrootelement annotation is not always generated.
Just the same, I have to work with a schema for which JAXB does not
(rightly) create the @XmlRootElement. What I need to do is make a string
out of the data, then get the JAXB object back out latter.

To create the String, I added a "wrapper" like this:

marshaller.marshal(new JAXBElement(
new QName("http://mydomain/schema/MyNamesape",
"MyMessage"),
MyMessageType.class, request), sw);

However, the code Netbeans creates to convert this String back to an XML
object gives me a java.lang.ClassCastException on the resulting Object.
I've confirmed that the data (String) is intact, and is what I expect.

Is there a general approach to making a JAXB object with no
@XmlRootElement pass through conversion to a String and back again?

Thanks
Thanks


--
View this message in context: http://www.nabble.com/Dealing-With-a-Schema-for-Which-There-is-No-xmlrootelement-tp21963039p21963666.html
Sent from the NetBeans - EntPack mailing list archive at Nabble.com.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> SOA Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo