2
I’m using the native class of PHP
to create a Soap server.
Example:
class Bar {
public function getDrink($age, $money, $name) {
if ($age >= 18 && $money == 5):
$drink = "Heineken";
else:
$drink = "water";
endif;
if (empty($name)): // name é um parametro opcional.
$name = "Hey ";
endif;
return $name . " here is your " . $drink;
}
}
$options = array('uri' => 'http://localhost/webservice');
$server = new SoapServer(NULL, $options);
$server->setClass('Bar');
$server->handle();
Then I can consume all the methods of the class Bar
in my Soapclient, however all parameters become mandatory. how I could specify to the server that some parameters of a given method will be optional?
The send of the arguments is based on the position, could set a default value for the parameters in the method signature.
– rray
@rray apparently this will be my worst problem, because I will have to force people to enter some value in the parameters to avoid the risk of a value going to another parameter, because as you said they take the position and not the name.
– Gabriel Rodrigues
I do not know if this is a problem, you are the server so sets the operating rules the client who will consume need only know and follow their rules otherwise it will not achieve the goal.
– rray