About the Author

author photo

Adam Trachtenberg is the Director of the LinkedIn Developer Network, where he oversees developer relations and marketing for the LinkedIn Platform. Before LinkedIn, Adam worked at eBay in platform product management and marketing. Even earlier, he co-founded Student.Com and TVGrid.com. Adam is the author of PHP Cookbook and Upgrading to PHP 5. He lives in San Francisco.

See All Posts by This Author

How ext/soap converts SOAP data structures to PHP

I haven’t seen any documentation on how ext/soap converts SOAP results to PHP data structures, so I thought I would make a quick blog entry. If I get time, I will try to make this all pretty, confirm I am actually correct, and add it to the official docs.

Normally, the conversion is simple:

Adam

Becomes an attribute of “Person” and a value of “Adam” under a stdClass instance.

stdClass Object
(
[Person] => Adam
)

Attributes are also converted to properties:

stdClass Object
(
[gender] => male
)

When there is both text and attributes, the text is mapped to a property name of _ (underscore).

stdClass Object
(
[Person] => stdClass Object
(
[_] => Adam
[gender] => male
)

)

Of all the bits that might trip you up, this underscore mapping bit is it, as I don’t know where this came from. :)

However, it’s only done when there is straight-up text. If there is a nested XML element, then this doesn’t happen, as in:

Adam

This becomes:

stdClass Object
(
[Person] => stdClass Object
(
[Name] => Adam
[gender] => male
)

)

That’s all for now. The OSCON WiFi connection is super slow.

There Are 5 Responses So Far. »

  1. I think wordpress ate your code examples. I don’t like it when wordpress does that. Bad wordpress!

  2. Yea. Not only did it eat whitespace, it ate XML elements and attributes. Sorry.

  3. PHP5

    PHP5 is going to be the focus of much of my time in the coming year or so – here’s a couple of pointers as to resources on this new version of the scripting language.

  4. Hi Adam,

    I am new to soap. I search everywhere and still can’t find an answer or maybe I am going in the wrong direction and this is not possible. What does it mean when the client expect a returned of an XML Document in this format:

    How can we returned .xml doc? Ever heard of this? I know we can returned string, float, array, etc. Do you have any idea? I am using php soap.

    Phil

  5. Not sure what you mean there.
    Do you just mean how to send an xml request using soap?

Post a Response