note 80715 added to function.soap-soapclient-construct
| From: | james dot ellis at gmail dot com | Date: | Wed, 30 Jan 2008 01:10:21 +0000 |
| Subject: | note 80715 added to function.soap-soapclient-construct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135571@lists.php.net to get a copy of this message | ||
A note regarding boolean values that may seem obvious on reflection but could be a gotcha for some:
Seeing a SOAP request example with <SomeBooleanParam>true</SomeBooleanParam> may lead
you to pass in string "true" or "false" as the parameter, which is incorrect -
the correct method is to use boolean data types.
<?php
$client = new SoapClient($wsdl,$options);
$method = "DoSomething";
$params = new stdClass;
$params->SomeBooleanParam = TRUE;
$client->$method($params);
/**
simplified request snippet would be
<SomeBooleanParam>true</SomeBooleanParam>
**/
//this will also be correct, but not for the right reasons:
$params->SomeBooleanParam = "true";
$client->$method($params);
/**
simplified request snippet would be
<SomeBooleanParam>true</SomeBooleanParam>
**/
//this is where you may be wondering what is going on
$params->SomeBooleanParam = "false";
$client->$method($params);
/**
simplified request snippet would be
<SomeBooleanParam>true</SomeBooleanParam>
**/
//you need to do this instead
$params->SomeBooleanParam = FALSE;
$client->$method($params);
/**
simplified request snippet would be
<SomeBooleanParam>false</SomeBooleanParam>
**/
?>
Hope that helps!
----
Server IP: 203.202.10.60
Probable Submitter: 58.6.148.157
----
Manual Page -- http://www.php.net/manual/en/function.soap-soapclient-construct.php
Edit -- https://master.php.net/note/edit/80715
Del: integrated -- https://master.php.net/note/delete/80715/integrated
Del: useless -- https://master.php.net/note/delete/80715/useless
Del: bad code -- https://master.php.net/note/delete/80715/bad+code
Del: spam -- https://master.php.net/note/delete/80715/spam
Del: non-english -- https://master.php.net/note/delete/80715/non-english
Del: in docs -- https://master.php.net/note/delete/80715/in+docs
Del: other reasons-- https://master.php.net/note/delete/80715
Reject -- https://master.php.net/note/reject/80715
Search -- https://master.php.net/manage/user-notes.php