Re: Gensym, SOAP::Lite & Perl

[email protected] (ammarmar)
Newsgroups php.soap
Message-ID <[email protected]>
>
> When I receive back a response from the SOAP Server, the data is wrapped  
> in gensym tags:
> ...
> <API_ExecuteResponse xmlns="http://server.co.uk/API">
> <s-gensym1437 xsi:type="xsd:string">
> remote_pass</s-gensym1437>
> <s-gensym1439 xsi:type="xsd:string">
> *****</s-gensym1439>
> <s-gensym1441 xsi:type="xsd:string">
> password</s-gensym1441>
> <s-gensym1443 xsi:type="xsd:string">
> *****</s-gensym1443>
> <s-gensym1453 xsi:type="xsd:string">
> error_string</s-gensym1453>
> <s-gensym1455 xsi:nil="true" />
> </API_ExecuteResponse>
> ...
> In the Perl code, the above is handled internally, and it will create  
> the key=>value pairs as an array. However, I can't get this to work in  
> PHP.


PHP SoapClient should produce StdClass object with fields s-gensym1437,  
s-gensym1439, etc, e.g.:

object(stdClass)#1 (2) {
   ["s-gensym1234"]=>
   string(3) "xyz"
   ["s-gensym1235"]=>
   string(3) "abc"
}

You should be able to iterate on this object using foreach. If you prefer  
working on arrays, you can do something like this:

$gensym = array();

foreach ($result as $name => $value)
{
	// if name contains "s-gensym"
	if (false !== strpos($name, "s-gensym"))
	{
		$gensym[] = $value;
	}
}

Resulting $gensym array will contain all string values sent as  
s-gensym****.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.