Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Webservice - compley type and array

Status
Not open for further replies.

szmgg

Programmer
Nov 29, 2003
8
HU
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 automatically?

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:
<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=" xmlns:xsd=" xmlns:xsi="- <soapenv:Body>
- <getDataSetResponse xmlns="- <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?
 
Why do you say the other option is wrong? I think it's being generated OK.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top