You should convert all collections to arrays -- especially if your goal is interoperability with non-Java applications. As an alternative to doing the class clasting in your code, you could write your own schema for the information and custom serializers.

Anne

On 2/14/06, Giggle Giggle <[EMAIL PROTECTED]> wrote:
Hi,
after several hours I've solved the probem how to send a java collection over soap ("Wrapper" pattern):

public class CustomerManager {

    private Set<Customer> customers = new HashSet<Customer>();

    public Set<Customer> getCustomers() {
        customers.add(new Customer(21, "Paul"));
        customers.add(new Customer(22, "Peter"));

        return customers;
    }

Wrapper:
-------------
public class CustomerManagerWrapperSoapBindingImpl implements test.CustomerManagerWrapper{

    protected CustomerManager cm = new CustomerManager();

    public test.Customer [] getCustomers() throws java.rmi.RemoteException {
        return (Customer[]) cm.getCustomers().toArray(new Customer[0]);
    }
}

Well, works fine, but only when the Customer class has only "primitive" atributes.
But I want to apply this pattern on Customers which includes another collection (I use Hibernate, collections means one-to-many mapping for example):

// for example
private Set kids;

Is there any possible way except creating another wrapper (around Customer class)?

Thanks for any comments
Lucas

Reply via email to