users@jax-rpc.java.net

Re: Return an array of objects

From: Doug Kohlert <Doug.Kohlert_at_Sun.COM>
Date: Tue, 06 Sep 2005 13:06:03 -0700

Mariano,
It looks like you are using rpc/encoded. In this case you should use
SOAP encoded arrays. Here is an
example from the SOAP 1.1 spec at:
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/

<element name="ArrayOfPhoneNumbers">
  <complexType base="SOAP-ENC:Array">
    <element name="phoneNumber" type="tns:phoneNumber"
maxOccurs="unbounded"/>
  </complexType>
  <anyAttribute/>
</element>

Mariano García wrote:

>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!
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jax-rpc.dev.java.net
>For additional commands, e-mail: users-help_at_jax-rpc.dev.java.net
>
>
>

-- 
 - Doug