You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michal Dorsett <mi...@xeaglex.com> on 2003/05/19 20:32:49 UTC

Returning objects with array members

I have a web service that exposes the following interface method:

public GetBranches_Ret getBranches()

GetBranches_Ret is defined as follows:

public class GetBranches_Ret
{
public ReturnStatus status;
public Branch [] branches;

public GetBranches_Ret() {}
}

============================================================

The following lines in my Server_config.wsdd define the (de)serializer
factories that relate to this method and return object:

<typeMapping
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns5:GetBranches_Ret"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
type="java:my.url.ws.endpoints.returnobjects.GetBranches_Ret"
xmlns:ns5="http://returnobjects.endpoints.ws.url.my"/>

...

<typeMapping
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
qname="ns44:ArrayOffBranch"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
type="java:my.url.ws.objects.Branch[]"
xmlns:ns44="http://objects.ws.url.my"/>

============================================================

The following is a snippet from the SOAP response generated when a user
invokes my service calling getBranches:

- <ns1:getBranchesResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://localhost:8080/web_service/services/FocusWebService">
<getBranchesReturn href="#id0" />
</ns1:getBranchesResponse>
- <multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:GetBranches_Ret"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://returnobjects.endpoints.ws.url.my">
<status href="#id1" />
<branches href="#id2" />
<branches href="#id3" />
<branches href="#id4" />
<branches href="#id5" />
<branches href="#id6" />
<branches href="#id7" />
<branches href="#id8" />
<branches href="#id9" />
<branches href="#id10" />
<branches href="#id11" />
<branches href="#id12" />
<branches href="#id13" />
<branches href="#id14" />
<branches href="#id15" />
<branches href="#id16" />
<branches href="#id17" />
<branches href="#id18" />
</multiRef>
- <multiRef id="id1" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns3:ReturnStatus" xmlns:ns3="http://objects.ws.url.my"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<code xsi:type="xsd:int">0</code>
<message xsi:type="xsd:string" />
</multiRef>


============================================================

Previously we used Sun's SOAP toolkit, which returns what seems to be a more
appropriate response:

- <ans1:getBranchesResponse
xmlns:ans1="http://localhost:8090/FocusWebService/wsdl/FocusWebService">
<result href="#ID1" />
</ans1:getBranchesResponse>
- <ns0:GetBranches_Ret id="ID1" xsi:type="ns0:GetBranches_Ret">
<status href="#ID2" />
<branches href="#ID3" />
</ns0:GetBranches_Ret>
- <ns0:ReturnStatus id="ID2" xsi:type="ns0:ReturnStatus">
<code xsi:type="xsd:int">0</code>
<message xsi:type="xsd:string" />
</ns0:ReturnStatus>
- <ns0:ArrayOfBranch id="ID3" xsi:type="enc:Array"
enc:arrayType="ns0:Branch[17]">
<item href="#ID4" />
<item href="#ID5" />
<item href="#ID6" />
<item href="#ID7" />
<item href="#ID8" />
<item href="#ID9" />
<item href="#ID10" />
<item href="#ID11" />
<item href="#ID12" />
<item href="#ID13" />
<item href="#ID14" />
<item href="#ID15" />
<item href="#ID16" />
<item href="#ID17" />
<item href="#ID18" />
<item href="#ID19" />
<item href="#ID20" />
</ns0:ArrayOfBranch>


============================================================

My problem is:

The response generated by Axis does not seem to encode the branches array as
an array, but rather as an ad-hoc list of objects stored in the return
object. If there were 50 branches they would have been returned as 50
individual objects instead of being wrapped in an array.

Can someone show me how to set up my Server_config.wsdd so the array is
returned as an array wrapping branch objects?

Thanks in advance,

Michal Dorsett