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:
<xsd:complexType name="LoginReq">
<xsd:all>
<xsd:element name="username" type="xsd:string" nillable="true"/>
<xsd:element name="password" type="xsd:string" nillable="true"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="LoginResp">
<xsd:all>
<xsd:element name="errorCode" type="xsd:string" nillable="true"/>
</xsd:all>
</xsd:complexType>
EDIT2: I just found that to declare an element as required/optional you need to use minOccurs/maxOcurrs
. Both of them default to 1, so every element is required by default. In order to declare an optional element, you declare it with minOccurs="1"
. Nillable is just for allowing elements to be empty. Again, how do i declare an element as optional (so Zend adds minOccurs="0" to that element)?