Don't do "soapenc:arrayType " . 

For an example of arrays of complex types, running on AXIS 1.2 RC3, see
http://dinoch.dyndns.org:7070/axis1.2/AboutCtService.jsp


 

-----Original Message-----
From: Deepak S Patwardhan [mailto:[EMAIL PROTECTED] 
Sent: Saturday, March 05, 2005 2:36 AM
To: [email protected]
Subject: Arrays in WSDL

Hi all,

I am a new user and this is my first mail. I am learning to use axis and
WSDL for making web services. I am stuck with arrays at the moment.

Let me describe my toy application. I have a GeometryService which has
two ports. One of them is supposed to take a list of points (on a plane)
and return whichever is the farthest from the origin. Silly thing to do,
but the intention is to understand how to pass arrays in SOAP. The
following is the WSDL file :

<?xml version="1.0" ?>

<!-- Functionality to be provided                       -->
<!-- double distance(Point2D p1, Point2D p2)            -->
<!-- Point2D farthest(List l1)                          -->

<definitions name="GeometryDef"
         targetNamespace="Geometry"
         xmlns:tns="Geometry"
         xmlns:typens="Geometry"
         xmlns:xsd="http://www.w3.org/1999/XMLSchema";
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
         xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
         xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
         xmlns="http://schemas.xmlsoap.org/wsdl/";>

     <!-- Other than predefined types, I need the following -->
     <types>
         <!-- A type for points -->
         <xsd:complexType name="Point2D">
             <xsd:sequence>
                 <xsd:element name="x_coordinate" type="xsd:double"/>
                 <xsd:element name="y_coordinate" type="xsd:double"/>
             </xsd:sequence>
         </xsd:complexType>

         <!-- A type for arrays of point -->
         <xsd:complexType name="ArrayOfPoint2D">
             <xsd:complexContent>
                 <xsd:restriction base="soapenc:Array">
                     <attribute ref="soapenc:arrayType"
                             wsdl:arrayType="typens:Point2D[]"/>
                 </xsd:restriction>
             </xsd:complexContent>
         </xsd:complexType>
     </types>

     <!--        Message declarations            -->
     <!-- kind 1 : carrying two points           -->
     <!-- kind 2 : carrying a double             -->
     <!-- kind 3 : carrying a point              -->
     <!-- kind 4 : carrying many points          -->

     <message name="TwoPoints">
         <part name="p1" type="tns:Point2D"/>
         <part name="p2" type="tns:Point2D"/>
     </message>

     <message name="ADouble">
         <part name="doub" type="xsd:decimal"/>
     </message>

     <message name="APoint">
        <part name="p3" type="tns:Point2D"/>
     </message>

     <message name="ManyPoints">
         <part name="pList" type="tns:ArrayOfPoint2D"/>
     </message>

     <!-- Port type declarations                         -->
     <portType name="Planar">
         <operation name="distance">
             <input message="tns:TwoPoints"/>
             <output message="tns:ADouble"/>
         </operation>
         <operation name="farthest">
             <input message="tns:ManyPoints"/>
             <output message="tns:APoint"/>
         </operation>
     </portType>

     <!-- bindings -->
     <binding name="GeometrySOAPBinding" type="tns:Planar">
         <soap:binding style="rpc"
 
transport="http://schemas.xmlsoap.org/soap/http/"/>

         <operation name="distance">
             <soap:operation soapAction=""/>
             <input>
                 <soap:body use="encoded"
                            namespace="Geometry"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
             </input>
             <output>
                 <soap:body use="encoded"
                            namespace="Geometry"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
             </output>
         </operation>

         <operation name="farthest">
             <soap:operation soapAction=""/>
             <input>
                 <soap:body use="encoded"
                            namespace="Geometry"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
             </input>
             <output>
                 <soap:body use="encoded"
                            namespace="Geometry"

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
             </output>
         </operation>
     </binding>

     <!-- service declaration-->
     <service name="GeometryService">
         <port name="Planar" binding="tns:GeometrySOAPBinding">
             <soap:address
location="http://jaganmohini.cse.iitd.ac.in:8080/axis/Planar/"/>
         </port>
     </service>
</definitions>


***************************************************************

When I run WSDL2Java on this file, a class is generated by the name 
Geometry.ArrayOfPoint2D. However, the class contains nothing which
points to 
the fact that it is supposed to be an array of Point2D. It has no
members.

Ques ) How am I supposed to make use this class. How can a client make
an array 
of points to send to the service ?

Or am I missing something in the type declarataion ?

thanks,
Deepak S Patwardhan.

Reply via email to