Re: WSIF with Java Reflection or with Jaxme (or xstream)
Aleksander Slominski <[email protected]> Mon, 07 Nov 2005 12:11:34 -0500
| Newsgroups | gmane.comp.apache.webservices.wsif.user |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: >Re-hello, > > > >No answers? > > > >I wonder if I use Java Reflection (with setter methods) of stubs to fill input parameter object (for complex type). > >OR > >Use jaxme > JAXB? > (or xstream) to manipulate XML stream. Set attributes to correct values and generated from the XML stream the appropriate object. > that solution seems to be Java specific as xstream generates XML based on Java object tree/graph? > > >Somebody can give an opinion or its experience about this solution? > as such why to bother with AXIS or WSIF? why not just open HTTP connection and do POST(using apache httpclient or even built in JDK APIs) with XML data - if service endpoint is SOAP just wrap it into SOAP:Envelope/SOAP:Body that would be a simple and robust solution - working with reflection, generation of stub dynamically etc. is possible but may require lot of time and anyway it does not seem worth effort until you need multi-protocol WSDL binding capabilities of WSIF ... best, alek > >----------------------------------------------------------------- > >Hello everybody, > > > > > >I use WSIF to invoke dynamically a Web Service: > > > >I try this: > > > >1 - Get the WSDL endpoint, operation name .... To call. My operation > >take a complex type (new Person(name,firstname)) as input parameter and > >return a String (hello <name> <firstname>) > > > >2 - Generate in fly Java Stubs using Axis 1.2.1 > > > >3 - Get the dynamic class (from a ClassLoader class), fill this > >instantiated object with setters methods using Java Reflection > > > >4 - Set this dynamic object as an input parameter > >(input.setObjectPart("Person_1", dynamicObject)). (Map this type with > >service.mapType function) > > > >5 - Call the WSIF executeRequestResponseOperation method. > > > >It's works fine. > > > > > > > >Now, I want to do the step 3 dynamically. Use Java Reflection to set all > >the fields correctly with the user input value it's quiet complicated I > >think. > > > > > > > >So, I wonder whether with xstream API it will be easier. > > > >1 - Get the WSDL endpoint, operation name .... > > > >2 - Generate in fly Java Stubs using Axis 1.2.1 > > > >3 - Get the dynamic class (from a ClassLoader class) of the input part > >of the operation and generate the XML stream using xtream API > > > >4 - Represent this XML stream as a JTree for the user who fill this. And > >with this XML stream which is filled with user values, deserialize the > >object back from the XML using xstream. > > > >5 - Set the object generated by xstream as an input parameter > >(input.setObjectPart("Person_1", xstreamGeneratedObject)) > > > >6 - Call the WSIF executeRequestResponseOperation method > > > > > > > >Is somebody have already try this? (or a similar solution?) > > > > > > > >I try to generate the XML stream from the stub generated by Axis, but > >the fields are not initialized with default value. So, the XML stream is > >empty. > > > >For example, if I can get a Java Stubs from Axis like this (with a > >default constructor which init nom and prenom to "" ): > > > > > > > >package stubs.MyHelloServiceDme; > > > > > > > >public class HelloObj implements java.io.Serializable { > > > > private java.lang.String nom; > > > > private java.lang.String prenom; > > > > > > > > public HelloObj() { > > > > this.nom=""; > > > > this.prenom=""; > > > > } > > > > > > > > public java.lang.String getNom() { > > > > return nom; > > > > } > > > > > > > >I can get the XML stream: > > > > > > > ><stubs.MyHelloServiceDme.HelloObj> > > > > <nom></nom> > > > > <prenom></prenom> > > > > <____hashCodeCalc>false</____hashCodeCalc> > > > ></stubs.MyHelloServiceDme.HelloObj> > > > > > > > >Then, I can fill the XML stream <nom> and <prenom> elements, get a Java > >Object from the XML stream filled, and pass it to WSIF to invoker > >operation. > > > > > > > >Thanks to help me. > > > > > > > >Delphine. > > > > > -- The best way to predict the future is to invent it - Alan Kay