RE: [SOAP] Defining array of arbitrary type or sequence elements with PEAR::SOAP
| From: | Javier Muniz | Date: | Tue, 22 Jul 2003 21:50:45 +0000 |
| Subject: | RE: [SOAP] Defining array of arbitrary type or sequence elements with PEAR::SOAP | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-875@lists.php.net to get a copy of this message | ||
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