This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes schemaLocation ignored when marshalling JAXB Classes using Metro Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "schemaLocation ignored when marshalling JAXB Classes using Metro" Watch "schemaLocation ignored when marshalling JAXB Classes using Metro" New topic
Author

schemaLocation ignored when marshalling JAXB Classes using Metro

Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
This is a question that was posted on StackOverflow, that nobody has answered yet.
I hope nobody minds me repeating the question here at the saloon:

I'm using the Metro stack bundled with Java 6 SE to call a web service. The web service expects XML as a parameter. I use JAXB classes to create content and pass my JAXB root element to the web service endpoint.

Now to my Problem: I can't find any way to make the marshaller include the schemaLocation of the XSD file since I can't directly access the marshaller. (If you have direct access to the marshaller it is possible do set the schemalocation as a property, but when using metro, all the marshalling seems to be happening internally.)

I've tried setting the xsi:schemaLocation in the XmlSchema annotation in the generated package-info.java class, but this had no effect on the xml generated.


Does anyone have any ideas how to solve this problem?
Rizwan Patel
Ranch Hand

Joined: Jan 03, 2008
Posts: 59
You can set this property on the Marshaller for including the namespace in generated XML.


scjp 1.5, OCPJWSD 5
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
Thank you for your reply, but I already know hat. If you read my posting carefully, you will See hat your suggestion is not an option. I dont have access to the marshaller as I am passing my jaxb object directly to the webservice end point. My Guess is that Metro uses the marshaller internally.
 
jQuery in Action, 2nd edition
 
subject: schemaLocation ignored when marshalling JAXB Classes using Metro