Re: [SOAP] Defining array of arbitrary type or sequence elements

From: Date: Wed, 30 Jul 2003 18:57:18 +0000
Subject: Re: [SOAP] Defining array of arbitrary type or sequence elements
References: 1  Groups: php.soap 
Request: Send a blank email to php-soap+get-888@lists.php.net to get a copy of this message
So, let me see if I have this straight: You have a SOAP_Transfer_Server class that handles the incoming connections. This is where the __typedef array listed below resides. You then have a TransferInformation class which has member variables $ServerID, $Directory, and $File. This class also has a __to_soap() function that returns a new SOAP_Value. You then append the serialized TransferInformation SOAP_Values to the $transferlist, then return this as a serialized SOAP_Value. I think I understand it, but if you could post a sample transaction wire, I think that would help immensely. Also, if you could post the TransferInformation class, that would be a BIG help, too. I hope this isn't asking too much! Thanks! Javier Muniz wrote:
Yes, I've done it in my test webservice using the following typedefs: $this->__typedef['{http://granicus.com/xsd}TransferInformation'] =
                    array(
                        'ServerID' => 'int',
                        'Directory' => 'string',
                        'File' => 'string'
                         );
$this->__typedef['{http://granicus.com/xsd}TransferList'] = array(array('{http://granicus.com/xsd}TransferInformation')); Then within my function I do: $transferlist = array(); while(I still have transfer entries) { $transferinfo = new TransferInformation() // transfer information class that contains __to_soap() function similar to example_type $transferlist[] = $transferinfo->__to_soap(); } return new SOAP_Value("output",'{http://granicus.com/xsd}TransferList',$transferlist); Hopefully that makes sense. I left out the dispatch map for the function and the class definition from TransferInformation(), but it generates the array of TransferInformation entries and returns them to my .NET and PHP clients properly. -Javier -----Original Message----- From: Gendron Bruno [mailto:b.gendron@umontreal.ca] Sent: Tuesday, July 22, 2003 1:07 PM To: soap@lists.php.net Subject: [SOAP] Defining array of arbitrary type or sequence elements with PEAR::SOAP Hi, Again, I'm posting this message hoping to resolve the following problem with PEAR::SOAP... By following Michele Manzato recommandations, I managed to define the following complex types to be used in automatic WSDL generation: <complexType name="Point"> <all> <element name="x" type="double" /> <element name="y" type="double" /> </all> </complexType> <complexType name="ResultSet"> <all> <element name="Count" type="int" /> <element name="Feature" type="Point" /> </all> </complexType> As you can see (and, from what I know, it always seems to be the case with PEAR::SOAP), the script returns my complex type as an <all><element/><element/>...</all> sequence, and I'm stuck with only 1 "Feature"-type element in my ResultSet... But what I really need is the following: <complexType name="ArrayOfFeatures"> <complexContent> <sequence> <element name="Feature" minOccurs="0" maxOccurs="unbounded" type="Point" /> <sequence> <complexContent> <complexType> <complexType name="ResultSet"> <sequence> <element name="Count" type="int" /> <element name="Features" nillable="true" type="ArrayOfFeatures" /> <sequence> <complexType> to be able to support more than 1 "Feature"-type element in my ResultSet... As I asked yesterday on this list, being able to define an array of arbitrary type would also do the trick: <complexType name="ArrayOfFeatures"> <complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType" wsdl:arrayType="Feature" /> <restriction> <complexContent> <complexType> Is this possible? Thanks for your help ---- Bruno Gendron Conseiller scientifique - Spécialiste en géomatique / Advisor - GIS Specialist Chaire de recherche du Canada en études asiatiques / Canada Chair of Asian Research Université de Montréal 3477, rue Jean-Brillant, bureau 530-26 C.P. 6128, Succ. Centre-ville Montréal, QC, Canada, H3C 3J7 Tél : +1 514-343-5768 Fax (CETASE) : +1 514-343-7716 Web : http://www.caac.umontreal.ca


« previous php.soap (#888) next »