Thanks for the quick reply!

That worked perfectly...

Thanks again,


// Chris Dunphy             


-----Original Message-----
From: Daniel Kulp [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 13, 2008 1:38 PM
To: [email protected]
Subject: Re: Using a JavaBean which contains a java.util.List property
with CXF JAX-WS/JAXB front-end


For Lists, per JAXB spec, only a setter is generated and it  
manipulates the live "list" that is stored in the object.   In your  
case, it would be something like:


public class MessageTO implements Serializable {
    ....
    private List<String> stuff = new ArrayList<String>();

    public List<String> getStuff() {
        return stuff;
    }

   ....
}

and you would populate it with something like:

msg.getStuff().addAll(myData);


That's what the spec calls for.  Note: getStuff() always returns a non- 
null list.  The stuff field always has a value.

Dan



On May 13, 2008, at 3:28 PM, Chris Dunphy wrote:

> Hello,
>
> I am trying to use this JavaBean object as a message that I am passing
> by around by means of a web service:
>
> *** MessageTO.java ***
>
> public class MessageTO implements Serializable {
>
>    private String description;
>    private long id;
>    private List<String> stuff;
>
>    public List<String> getStuff() {
>        return stuff;
>    }
>
>    public void setStuff(List<String> stuff) {
>        this.stuff = stuff;
>    }
>
>    public String getDescription() {
>        return description;
>    }
>
>    public void setDescription(String description) {
>        this.description = description;
>    }
>
>    public long getId() {
>        return id;
>    }
>
>    public void setId(long id) {
>        this.id = id;
>    }
> }
>
> *** end code sample ***
>
>
> I am trying to do this with Apache CXF 2.1 with the JAX-WS/JAXB
> implementation.  I can get most of it to work with the dynamic client,
> except for the List property "stuff", which doesn't work.
>
> Here is some code that I wrote that prints a list of methods and their
> parameters from the MessageTO bean class:
>
> *** code sample from dynamic client ***
>
>  URL[] classURLS = { new URL("http://mymessagews/MessageReceiver";) };
>        URLClassLoader classLoader = new URLClassLoader(classURLS);
>        DynamicClientFactory dcf = DynamicClientFactory.newInstance();
>        Client client =
> dcf.createClient("http://localhost:9000/MessageReceiver?wsdl";,
> classLoader);
>
>        Object message =
> Thread 
> .currentThread().getContextClassLoader().loadClass("mymessagews.Me
> ssageTO").newInstance();
>
>        Method[] methods = message.getClass().getMethods();
>        for (Method m : methods) {
>            System.out.print("[ Method name: " + m.getName());
>            Class[] params = m.getParameterTypes();
>            for (Class p : params) {
>                System.out.print("\n\tParam: " + p.getName());
>            }
>            System.out.print("\n\tReturn: " +
> m.getReturnType().getName());
>            System.out.println(" ]");
>        }
>
> *** end code sample ***
>
>
>
> *** output of above codesnippet ***
>
> [ Method name: getId
>       Return: long ]
> [ Method name: setDescription
>       Param: java.lang.String
>       Return: void ]
> [ Method name: setId
>       Param: long
>       Return: void ]
> [ Method name: getDescription
>       Return: java.lang.String ]
> [ Method name: getStuff
>       Return: java.util.List ]
> [ Method name: wait
>       Return: void ]
> [ Method name: wait
>       Param: long
>       Param: int
>       Return: void ]
> [ Method name: wait
>       Param: long
>       Return: void ]
> [ Method name: hashCode
>       Return: int ]
> [ Method name: getClass
>       Return: java.lang.Class ]
> [ Method name: equals
>       Param: java.lang.Object
>       Return: boolean ]
> [ Method name: toString
>       Return: java.lang.String ]
> [ Method name: notify
>       Return: void ]
> [ Method name: notifyAll
>       Return: void ]
>
> *** end output ***
>
> The getter seems to be there, but the setter is not. Is there any kind
> of annotation that I can use to get java.util.List to work, so that I
> can call the setStuff(List<String> stuff) method with the dynamic  
> JAX-WS
> client?
>
> Sadly, aegis is not an option because I can't get that to work with  
> the
> dynamic client.  I have poured over as much documentation as I could
> find, but I couldn't seem to find a way to get this working.
>
>
> Thanks!
>
>
> Chris Dunphy
> Software Developer, Enterprise Software Development
> Shaw Cablesystems G.P.  750-7417 [EMAIL PROTECTED]
> Suite 800 630 3rd Avenue SW, Calgary, Alberta, T2P 4L4
>
> try {
>    succeed();
> } catch (const failed_error& e) {
>    try {
>        try_again();
>    }
> }
>
>

---
Daniel Kulp
[EMAIL PROTECTED]
http://www.dankulp.com/blog




Reply via email to