users@jaxb.java.net

Sending arrays in objects.

From: Szmg <mate.szvoboda_at_gmail.com>
Date: Mon, 26 Jan 2009 14:22:33 -0800 (PST)

I'm trying to make a webservice that returns an array of objects, which
contains another array of objects.

Everything works fine, when I hack the wsdl manually.
How can I make it work without modify it?

I'm using
 Eclipse 3.4 for Java EE,
 Axis 1.4,
 Glassfish v2 UR2, and
 Eclipse's Web Services Explorer for testing.

My service method looks like this:
    public DataSet[] getDataSet(User owner) {
        DataSet[] res = new DataSet[2];
        res[0] = new DataSet();
        DataSet ds = res[0];
        ds.setName("DataSet1");
        ds.setDescription("No desc");
        ds.setIsDefault(false);
        String[] ss = {"One", "Two"};
        ds.setColumns(ss);
        return res;
    }

DataSet is a simple JavaBean:

public class DataSet implements java.io.Serializable {
    private String name;
    private String description;
    private boolean isDefault;
    private String[] columns;
    
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public boolean getIsDefault() {
        return isDefault;
    }
    public void setIsDefault(boolean isDefault) {
        this.isDefault = isDefault;
    }
    public String[] getColumns() {
        return columns;
    }
    public void setColumns(String[] columns) {
        this.columns = columns;
    }

}

Generated WSDL part:
   <element name="getDataSetResponse">
    <complexType>
     <sequence>
      <element maxOccurs="unbounded" name="getDataSetReturn"
type="impl:DataSet"/>
     </sequence>
    </complexType>
   </element>
   <complexType name="ArrayOf_xsd_string">
    <sequence>
     <element maxOccurs="unbounded" minOccurs="0" name="item"
type="xsd:string"/>
    </sequence>
   </complexType>
   <complexType name="DataSet">
    <sequence>
     <element name="columns" nillable="true"
type="impl:ArrayOf_xsd_string"/>
     <element name="description" nillable="true" type="xsd:string"/>
     <element name="isDefault" type="xsd:boolean"/>
     <element name="name" nillable="true" type="xsd:string"/>
    </sequence>
   </complexType>


It works when I set the name of the element of "ArrayOf_xsd_string" to
"columns". (<element maxOccurs="unbounded" minOccurs="0" name="columns"
type="xsd:string"/>)




SOAP response:
- <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <getDataSetResponse xmlns="http://score.com">
- <getDataSetReturn>
- <columns>
  <columns>One</columns>
  <columns>Two</columns>
  </columns>
  <description>No desc</description>
  <isDefault>false</isDefault>
  <name>DataSet1</name>
  </getDataSetReturn>
  <getDataSetReturn xsi:nil="true" />
  </getDataSetResponse>
  </soapenv:Body>
  </soapenv:Envelope>



Any idea?
-- 
View this message in context: http://www.nabble.com/Sending-arrays-in-objects.-tp21674015p21674015.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.