2008年12月19日星期五

RE: [fw-webservices] Zend_Soap_Autodiscover: how to generate minOccurs and maxOccurs in WSDL

Hello,

A little patch can be done in DefaultComplexType.php (version 1.7.1). I use
the description part of @var to set the minOccurs and maxOccurs values. Your
class declaration becomes :
/

class FilterScript_Authentication {
/**
* Username
*
* @var string ___FOR_ZEND_minOccurs=1 ___FOR_ZEND_maxOccurs=1
*/
public $username;
/**
* Password ___FOR_ZEND_minOccurs=1 ___FOR_ZEND_maxOccurs=1
*
* @var string
*/
public $password;
}

and the output is :
<xsd:complexType name="FilterScript_Authentication">

<xsd:all>
<xsd:element name="username" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element name="password" type="xsd:string" minOccurs="1" maxOccurs="1"/>
</xsd:all>
</xsd:complexType>

The patch is to be placed after line 58 ($element->setAttribute('type',
$this->getContext()->getType(trim($matches[1][0])));) and is :
// Patrick
$tempo = $property->getDocComment();
if
(preg_match('/___FOR_ZEND_minOccurs\s*=\s*(\d+|unbounded)/',$tempo,$matches))
{
$element->setAttribute('minOccurs', $matches[1]);
}
if
(preg_match('/___FOR_ZEND_maxOccurs\s*=\s*(\d+|unbounded)/',$tempo,$matches))
{
$element->setAttribute('maxOccurs', $matches[1]);
}
// Patrick end

Best regards,
Patrick

Alexander Veremyev wrote:
>
> Hi Dieter,
>
>
>
> No, it doesn't have such possibility now.
>
>
>
> Type info is retrieved from a docblock now. There is no appropriate tag
> to specify if class property is required.
>
> Still think about API for such possibility...
>
>
>
> With best regards,
>
> Alexander Veremyev.
>
>
>
> ________________________________
>
> From: Dieter Devlieghere [mailto:dieter.devlieghere@extendit.be]
> Sent: Tuesday, August 05, 2008 4:18 PM
> To: fw-webservices@lists.zend.com
> Subject: [fw-webservices] Zend_Soap_Autodiscover: how to generate
> minOccurs and maxOccurs in WSDL
>
>
>
> Hi,
>
>
>
> I'm trying to generate a WSDL with Zend_Soap_Autodiscover.
>
>
>
> Does anyone know if it's possible to make it generate minOccurs and
> maxOccurs attributes in a self-defined complex type?
>
>
>
> I have a class that defines a complex type:
>
> /**
>
> * Authentication object: username and password
>
> *
>
> */
>
> class FilterScript_Authentication {
>
> /**
>
> * Username
>
> *
>
> * @var string
>
> */
>
> public $username;
>
> /**
>
> * Password
>
> *
>
> * @var string
>
> */
>
> public $password;
>
> }
>
>
>
> This is what Zend_Soap_Autodiscover generates:
>
> <xsd:complexType name="FilterScript_Authentication">
>
> <xsd:all>
>
> <xsd:element name="username" type="xsd:string"/>
>
> <xsd:element name="password" type="xsd:string"/>
>
> </xsd:all>
>
> </xsd:complexType>
>
>
>
> And I would like it to generate this:
>
> <xsd:complexType name="FilterScript_Authentication">
>
> <xsd:all>
>
> <xsd:element minOccurs="1" maxOccurs="1" name="username"
> type="xsd:string"/>
>
> <xsd:element minOccurs="1" maxOccurs="1" name="password"
> type="xsd:string"/>
>
> </xsd:all>
>
> </xsd:complexType>
>
>
>
>
>
> Greets,
>
> Dieter Devlieghere
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date:
> 05.08.2008 6:03
>
>
>
>

--
View this message in context: http://www.nabble.com/Zend_Soap_Autodiscover%3A-how-to-generate-minOccurs-and-maxOccurs-in-WSDL-tp18829870p21094577.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

没有评论: