Ever looked into Axis MSG style calls?  This is client code, but you can do
the same thing on the server side as well, assuming you've built a MSG style
service.  Check out the Axis docs for more information.

Service service = new Service();
Call call = (Call) service.createCall();
call.setSOAPActionURI("MyOperationName");
call.setTargetEndpointAddress("http://localhost:8080/services/MyService";);

SOAPBodyElement body = new SOAPBodyElement(doc.getDocumentElement());
body.setNamespaceURI("");
call.invoke(new SOAPBodyElement[]{body});

-Jon

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 17, 2004 2:40 PM
To: [EMAIL PROTECTED]
Subject: Populate WSDL2Java object from XML file.


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.

Reply via email to