This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Web Services and the fly likes Using JAX-WS with JAXB problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Using JAX-WS with JAXB problem" Watch "Using JAX-WS with JAXB problem" New topic

Using JAX-WS with JAXB problem

Komandir Kozlov

Joined: Jun 04, 2008
Posts: 15

How could I define namespace uri and prefix for nested elements in schema using JAXB?

I have next schema
<xs:element name="RequestXml">
<xs:element name="oInputXml">
<xs:element name="B2BAvailabilityRequest" >

and next code which deal with this JAXB generated beans

ObjectFactory factory = new ObjectFactory();
RequestXml requestXml = factory.createRequestXml();
RequestXml.OInputXml oInputXml = factory.createRequestXmlOInputXml();
RequestXml.OInputXml.B2BAvailabilityRequest req = factory.createRequestXmlOInputXmlB2BAvailabilityRequest();

// fill req here

JAXBElement<RequestXml> jRequest = factory.createRequestXml(requestXml);

Problem is that I could define namespase uri and prefix only for JAXBElement. But I need also to define prefix for oInputXml too. I could create JAXBElement from RequestXml.OInputXml

JAXBElement<RequestXml.OInputXml> oXml = factory.createRequestXmlOInputXml(oInputXml);

but then it can't be nested in JAXBElement<RequestXml>.

How could I define namespace prefix for xml element which would be generated from this bean? Should I do this in schema or there is programmatic methods?

Thanks in advance,
Komandir Kozlov

Joined: Jun 04, 2008
Posts: 15
Thanks for your answers . Problem was solved with use of annotations. Hope it would be helpful for someone.
I agree. Here's the link:
subject: Using JAX-WS with JAXB problem
jQuery in Action, 3rd edition