users@jax-rpc.java.net

Return an array of objects

From: Mariano García <mgarciagonzalez_at_telefonica.net>
Date: Tue, 06 Sep 2005 09:54:26 +0200

Hi all,

I posted this mail in jwsdp mailing list, but maube this should be the
correct one.

I am developing a webservice in my company, and I need some help with
some aspects (i am a little newbie with jwsdp).

I am using jax-rpc in order to develop my webservice, wrinting first the
WSDL file, and then generating the java file using wscompile.

I want to write a service that returns a list of objects. These objects
follow the javaBean convention (attributtes with set/get methods).

This is the WSDL code I have used:


<!-- ************** TYPES *************************** -->
<complexType name="ArrayOfmyObject">
  <complexContent>
    <restriction base="soap-enc:Array">
      <attribute ref="soap-enc:arrayType"
wsdl:arrayType="impl:myObject[]"/>
    </restriction>
  </complexContent>
 </complexType>

<!-- All the attributes are basic types, as int, string and dates -->
<element name="myObject">
    <complexType>
     <sequence>
      <element name="att1" type="xsd:int"/>
        [...]
     </sequence>
    </complexType>
</element>

<element name="getObjects">
    <complexType>
     <sequence>
      <element name="fromDate" type="xsd:dateTime"/>
      <element name="toDate" type="xsd:dateTime"/>
     </sequence>
    </complexType>
   </element>

<element name="getObjectsResponse">
    <complexType>
     <sequence>
      <element name="getmyObjectsReturn" type="impl:ArrayOfmyObject"/>
     </sequence>
    </complexType>
   </element>

[...]
<!-- ************** MESSAGES *************************** -->
   <wsdl:message name="getObjectsRequest">

      <wsdl:part element="impl:getObjects" name="dates"/>

   </wsdl:message>
   
   <wsdl:message name="getObjectsResponse">

      <wsdl:part element="impl:getObjectsResponse" name="objectList"/>

   </wsdl:message>


I don't know if this service defined ok, because I don't find enough info about how to return arrays of objects.

Wscompile has generated my implementation class in this way:

public javax.xml.soap.SOAPElement getObjects(java.util.Calendar
fromDate, java.util.Calendar toDate) throws
         java.rmi.RemoteException {
                        
        return null;
}

In this method I will use all the stuff in order to get all my objects
from a database. So, I need to convert a java List object a SOAPElement object.
Is this possible? I don't know how to do it.

It is sure that these questions are very easy for you, but I am very
newbie.

Thanks!