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

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

 



[Luis says he meant to post this here, so I'm taking the liberty of
replying direct to the list]

At 13:42 13/09/2003, Luis Ferrao wrote:
> 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'));


Thanks for the tip but i'm still unconfortable with defining types, i don't know if it's a lack of documentation or a lack of programming skills, maybe both actualy.

I can't even figure out what the urn (http://foo.bar) is supposed to mean,
it's that bad.

As a matter of fact i haven't found any pear::soap valid documentation
besides shane's talks :/

Luis

AFAIK there is no official PEAR::SOAP documentation, only the examples provided with the package, and Shane's presentation. Michele Manzato posted a very nice tutorial/reference here on 29th, that you might like to look at (still reading it, Michele! :P).

"http://something.here"; (like http://foo.bar) is the very confusing
convention that's become commonplace to describe namespaces in XML.
Simply put, a namespace is like a place or container in which you can
put your own methods, type definitions, XML elements and so on. Generally
speaking, if you invent your own XML vocabulary, or types, or web
services, you will probably put them in one or more namespaces (that
you have also invented). The point of this is so that there is no
confusion or ambiguity when people are referring to items of the same
name, but that came from different places, and therefore probably have
different meanings.

Illustration is everything, so here's a classic example:

Person A runs a bookstore and invents an XML vocabulary which includes
the element 'title' that refers to a book title, like this:

<title>Fly Fishing</title>

Person B runs a mail order comapny and invents an XML vocabulary which
includes the element 'title' that refers to a person's title (Mr, Mrs
etc.), like this:

<title>Miss</title>

Person C then comes along and writes an XML file using both the above
vocabularies to map each person from the mail order company's database
onto a list of books that they have previously purchased.

<record>
  <title>Mr</title>
  <firstname>Jon</firstname>
  <lastname>Doe</lastname>
  <title>How To Get Rich Quick</title>
  <title>Programming XML</title>
</record>

Which <title> elements in the record refer to book titles, and which
refer to people name titles? By human inspection, the answer is obvious,
but the computer has no way of knowing how to tell the elements apart.
So to solve the problem, we put the XML elements invented by person A
into a namespace called http://bookstore.com/elements and person B's
into http://mailorder.com. Those are a bit long to keep typing every
time we need them, so we make 'prefixes' for them that abbrieviate them;
we might call the first one 'bookstore' or 'bs' and the second one
'mailorder' or 'mo'. Then the XML file becomes:

<record>
  <mo:title>Mr</mo:title>
  <mo:firstname>Jon</mo:firstname>
  <mo:lastname>Doe</mo:lastname>
  <bs:title>How To Get Rich Quick</bs:title>
  <bs:title>Programming XML</bs:title>
</record>

We've now differentiated the elements in a machine-processable way.

The confusing part is the trend to use namespace names like
http://foo.bar - when no such page exists on the web, and when HTTP
isn't even relevant to it at all. The computer does not attempt to
access any kind of pages or data at the namespace name you define, it
is just meant to be a unique identifier that nobody else would choose
(hence, it is common to use the name of your own web site or similar).

So, going back to the type definition:

> define('MY_NS', '{http://foo.bar}');
>
> $this->__typedef[MY_NS.'ArrayOfString'] = array(array('item' =>
'string'));

Here we are creating a namespace called http://foo.bar (it could be any name, but you should choose one that nobody else is likely to choose), and putting the type 'ArrayOfString' into it. Notice the syntax of __typedef is:

__typedef['{mynamespaceincurlybrackets}MyTypeName'] = ...;

The most concise explanation of how to define types with __typedef,
and examples of it, is the disco_server.php example in the 'examples'
folder of PEAR::SOAP.

Best,

Chris.

--
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