You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsif-user@ws.apache.org by de...@orsyp.com on 2005/11/04 17:31:34 UTC

WSIF, Java Reflection and xstream

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.