how works php soap server with attributes or is there a library that understands attributes?
I was trying to make a soap server in PHP and that works good, only the wsdl requires a attribute OptIn like:
<EmailAdresses> <Email OptIn="true">email@example.com</Email> </EmailAdresses>
Is there a good php library/classes that works with attributes? so that the Web service can return an array or something like that in a certain way and that those revenues to xml with attributes.
or how it works with the standard soap server from php ? because good documentation is hard to find.
thanks in advance
I've worked with SOAP services written in a number of languages, and I've never yet seen one which uses XML attributes -- they always simply use XML elements with a value inside the element (either a string or further elements).
I'm not saying you can't use attributes, but it seems that simple name-value pairs are a better fit for the kinds of data structures that most programming languages want to work with (ie simple variables or array trees).
But your question piqued my curiosity, so I've done a bit of digging for you.
As you say, the PHP manual really doesn't seem to be particularly forthcoming on the subject (which is unusual - it's generally quite a good resource), but if you really want to create attributes in your SOAP XML, I did find a few snippets which might help.
One suggestion which came up a few times was to use underscore as an array element in your data structure, and this would then become the value for the element, and other array keys would would become the attributes. Something like this:
$mydata = array('EmailAdresses' => array( 'Email' => array( '_' => 'firstname.lastname@example.org', 'OptIn' => 'true') ) );
The other suggestion I found was to create it as an object rather than as an array, using PHP's SimpleXML library, since this obviously explicitly allows the creation of XML attributes.
Sorry I don't have time to test those suggestions right now, but I hope that helps.