RE: [SOAP] [pear::soap - wsdl] Dispatch map for returning arrays (newbie)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 04:42 09/09/2003, Javier Muniz wrote:
Is there a way to specify a typedef for an array that could possibly contain
different types, i.e. array of mixed?  I'm not even sure if this is possible
in the SOAP spec but it would be incredibly useful for one of my
applications.

Thanks!

-Javier

The short answer: unfortunately, no (not yet!).


The long answer: recall that as of SOAP 0.8RC1, __typedef gets internalised
into WSDL-style data, therefore in the ideal long-run, anything that you can
define as a type in WSDL can be used in a __typedef.

WSDL supports XML Schemas, so you can define a type that is an array of
mixed elements of your choice like this:

<xsd:complexType name="mixedElement">
  <xsd:choice>
    <xsd:element name="item" type="xsd:string" />
    <xsd:element name="item" type="xsd:float" />
    ...
  </xsd:choice>
</xsd:complexType>

<xsd:complexType name="ArrayOfMixed">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:mixedElement[]" />
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>


If you want the array to be able to contain *any* type, you can forego the
<xsd:choice ... /> and just use type="xsd:anyType" instead.

Going back to the __typedefs, the latter type (ArrayOfMixed) can be made
like so:

$__typedef[MYNS.'ArrayOfMixed'] = array(array('item' => MYNS.'mixedElement'));

but unfortunately, there is currently no support for <xsd:choice> in
PEAR::SOAP, and no way of representing it via __typedef, so it is impossible
to create the 'mixedElement' type.

In the future, it is expected that __typedef will be replaced with a more
flexible mechanism for representing XML Schema types. We had to convert
the __typedef stuff to WSDL structures that match PEAR::SOAP's existing
WSDL file-handling structures first though, hence 0.8 :-)

Best,

Chris.

-----Original Message-----
From: Chris Coe [mailto:info@intelligentstreaming.com]
Sent: Monday, September 08, 2003 10:46 AM
To: soap@lists.php.net
Subject: Re: [SOAP] [pear::soap - wsdl] Dispatch map for returning arrays
(newbie)


At 20:03 07/09/2003, Luis Ferrao wrote: >Hi, > >This is a very simple question. >Let's say i want to creat a function (say testDB) that returns arrays >(i.e. 0 => zero, 1 => one, 2 => two, etc...) of unkown variable size. >What should my dispatch map look like ? > > >PHP:____________________________________________________ >$this->__dispatch_map['testDB'] = > array('in' => array('inputStringSimple' => 'string'), > 'out' => array(' ???? => ???? '), > ); ________________________________________________________

Although there may be a less convoluted way, you could define a type which
represents arrays of strings (or whatever your output elements are), and
refer to this type in your dispatch map:

define('MY_NS', '{http://foo.bar}');

$this->__typedef[MY_NS.'ArrayOfString'] = array(array('item' => 'string'));

$this->__dispatch_map['testDB'] =
     array('in' => array('inputStringSimple' => 'string'),
           'out' => array('databaseOutput' => MY_NS.'ArrayOfString'));

Since you have to specify a type name in the dispatch_map in/out values, and
no 'array of string' type exists by default, you have to define one.

>ps: if someone can at least point me to some dispatch map examples it
>would be great.

If you need a specific example, just ask :-)

Hope that helps.

Best,

Chris.

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux