Jasen - Since classes generated by wsdl2java are just POJOs you can use Java's
built in XMLEncoder class. There are a few pointers about this here:
http://mattpayne.org/b.cgi/Programming/Java/XMLEncoder.pf
-Matt
On Thu, 17 Jun 2004 14:39:52 -0400, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> How do you populate a WSDL2Java created object from an XML file?
>
> I've hunted around in the mailing list archives, and I've seen this question
> a few other times, but no answers that were clear enough for me to
> understand.
>
> Scenario: We have a WSDL which describes some service and imports some
> schema which describes some data structures. Run WSDL2Java on the WSDL and
> get out lots of nice Java. Typical usage is then to bind to a service
> endpoint URL, create a parameter object, populate it, and invoke the service
> with the method and parameter object.
>
> Like this:
> myService = new MyServiceLocator().getMyService(new URL(serviceEndpoint));
> _myObject requestObj = new _myObject();
> requestObj.setSomething(someValue);
> Status s = myService.request(requestObj);
>
> However, if _myObject is very complex, manually populating it is a pain.
> It'd be easier to have an XML document lying around that complies with the
> schema and just deserialize the XML into the WSDL2Java created object.
>
> I tried:
> DeserializerImpl myDeserializer =
> (DeserializerImpl)_myObject.getDeserializer("", _myObject.class, myQName);
> XMLReader reader =
> SAXParserFactory.newInstance().newSAXParser().getXMLReader();
> reader.setContentHandler(myDeserializer);
> reader.parse(new InputSource(new FileInputStream(filename)));
> _myObject myObj = (_myObject)myDeserializer.getValue();
>
> But all I get is an empty _myObject. I _THINK_ part of the issue is that
> the deserializer doesn't have access to the type mapping info in
> deploy.wsdd, but I'm at a loss how to get that info to the deserializer.
>
> Maybe this is worth putting in the Wiki?
>
> Help, please.
>
> Thanks.
>
> - Jasen.
>
>