i’m using Zend soap autodiscovery to generate a WSDL file for my web server. The problem is that every element of every complexType defaults to nillable=”true”. How do i declare elements as required? I read PHPDoc but found nothing.
EDIT: The code:
class MyService {
/**
* Identify remote user.
*
* @param LoginReq
* @return LoginResp
*/
public function login($request) {
// Code ….
}
}
class LoginReq {
/** @var string */
public $username;
/** @var string */
public $password;
}
class LoginResp {
/** @var string */
public $errorCode;
}Generated WSDL:
……………………………………..
if you have a default value set in your function definition, it will be nillable.
public function myMethod($argument = ‘hello’) {
// $argument is nillable
}If that isn’t it, can you post your code with doc blocks?
EDIT: Your code sample clarifies a lot.
If you look at Zend/Soap/Wsdl/Strategy/DefaultComplesType.php around line 76, you’ll see this:
// If the default value is null, then this property is nillable.
if ($defaultProperties[$propertyName] === null) {
$element->setAttribute(‘nillable’, ‘true’);
}That is the code that is determining if your “complex type” attribute is nillable. I would try updating your code to include a default value for the strings. Something like:
class LoginReq {
/** @var string */
public $username = ”;
/** @var string */
public $password = ”;
}If you do that, the === null should evaluate to false. Be sure your code handles the data validation properly, though.
If that doesn’t work, let me know!