users@jaxb.java.net

High-level JAXB/JAX-WS Question

From: Bill <saxton_at_gmail.com>
Date: Tue, 29 Jan 2008 13:03:10 -0500

Resending to proper "metro" alias...

I have a JAXB derived class, "com.mycompany.Config", that I use
throughout my application. I'm now trying to setup a web service that
a client can retrieve/save configuration information from/to. I
simply want to:

// Get the web service
MyWebService svc = new MyWebService();
Myport port = svc.getMyPort();

// Get the configuration
Config cfg = port.getConfig();

// Change around cfg values
// ...

// Now save configuration
port.saveConfig(cfg);

I'm using Netbeans to automatically create the web service client code
to make this easy. I'm somewhat confused, however, by the "Config"
class it actually returns. It seems that the web service doesn't
return the "com.mycompany.Config" class but, instead, a Class that it
derives from the JAXB schema (we'll call it "com.wsderived.Config".

Since "port.getConfig()" returns a "com.wsderived.Config" object
instead of a "com.mycompany.Config" one, it seems like, if I want to
use "Config" in a web service, I have to recode my application so that
everything uses "com.wsderived.Config" instead of
"com.mycompany.Config".

Does this make sense? Is it possible for the web service to return
"com.mycompany.Config" instead?

---
Here is a snippet of the getConfig() web service method, in case it helps:
---
import com.mycompany.Config;
// getConfig();
File file = new File("config.xml");
JAXBContext jc = JAXBContext.newInstance(com.mycompany.ObjectFactory.class);
Unmarshaller u = jc.createUnmarshaller();
Object obj = u.unmarshal(file);
JAXBElement<Config> config = (JAXBElement<Config>)obj;
return config.getValue();