Zend_Soap_Autodiscover: how to generate minOccurs and maxOccurs in WSDL

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Soap_Autodiscover: how to generate minOccurs and maxOccurs in WSDL

DerMika

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

Reply | Threaded
Open this post in threaded view
|

RE: Zend_Soap_Autodiscover: how to generate minOccurs and maxOccurs in WSDL

Alexander Veremyev

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:[hidden email]]
Sent: Tuesday, August 05, 2008 4:18 PM
To: [hidden email]
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

Reply | Threaded
Open this post in threaded view
|

Re: Can Zend_Soap_Server handle "simpleType" elements? 7A2-99B

Ingmar Heinrich-2
In reply to this post by DerMika
UNSUBSCRIBE

On Thu, Aug 7, 2008 at 5:03 PM, Dieter Devlieghere <[hidden email]> wrote:

It appears my message was blocked… resending according to the instructions…

 

From: Dieter Devlieghere
Sent: donderdag 7 augustus 2008 16:41
To: [hidden email]
Subject: Can Zend_Soap_Server handle "simpleType" elements?

 

I have a problem with the Zend_Soap_Server.

 

I have a WSDL that has a definition for a simple type in it:

            <xs:simpleType name="remarkstring">

                        <xs:restriction base="xs:string">

                                   <xs:maxLength value="50"/>

                                   <xs:minLength value="1"/>

                        </xs:restriction>

            </xs:simpleType>

 

This simple type is part of complex type:

<xs:complexType name="FilterScript_FilterPnrRequest">

            <xs:all>

                        <xs:element minOccurs="1" maxOccurs="1" name="recordlocator" type="xs:string"/>

                        <xs:element minOccurs="1" maxOccurs="1" name="officeid" type="xs:string"/>

                        <xs:element minOccurs="1" maxOccurs="1" name="queueIfAba" type="tns:FilterScript_GdsQueue"/>

                        <xs:element minOccurs="1" maxOccurs="1" name="queueIfAbc" type="tns:FilterScript_GdsQueue"/>

                        <xs:element minOccurs="0" maxOccurs="1" name="remarkIfAbc" type="tns:remarkstring"/>

            </xs:all>

</xs:complexType>

 

This complex type is automatically bound to this PHP class:

 

class FilterScript_FilterPnrRequest {

                /**

                 * @var string

                 */

                public $recordlocator;

                /**

                 * @var string

                 */

                public $officeid;

                /**

                 * @var FilterScript_GdsQueue

                 */

                public $queueIfAba;

                /**

                 * @var FilterScript_GdsQueue

                 */

                public $queueIfAbc;

                /**

                 * @var string

                 */

                public $remarkIfAbc;

}

 

The binding works, except the $remarkIfAbc: this variable is always empty. Since I based the definition of the simpleType remarkstring on the string datatype, this should work.

Also, if I send a soap message to my server with a remarkstring of more than 50 characters, the soap-server should send a "SOAP-ERROR: Encoding: Violation of encoding rules" error. It doesn't do this.

 

I suspect the Zend_Soap_Server is not capable of working with simpleTypes defined in the WSDL. Is this correct (or is it a bug ;)) ?

 

If this is a "todo": will there be support for simpleTypes anytime soon?

 

Greetings,

Dieter Devlieghere

 




--
Ingmar Heinrich <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

RE: Zend_Soap_Autodiscover: how to generate minOccurs and maxOccurs in WSDL

pduplouy
In reply to this post by Alexander Veremyev
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

Reply | Threaded
Open this post in threaded view
|

RE: Zend_Soap_Autodiscover: how to generate minOccurs and maxOccurs in WSDL

oscaroxy
This post has NOT been accepted by the mailing list yet.
I tried your solution and it' work fine, thanks

Now I've other problem:
I work with zend soap module, I create the class:

<?php

class Ticket{
             /**
             * @var string ___FOR_ZEND_minOccurs=0 ___FOR_ZEND_maxOccurs=1
             */
             public $Username;
             /**
             * @var string ___FOR_ZEND_minOccurs=0 ___FOR_ZEND_maxOccurs=1
             */
        public $Password;
        /**
         * @var string ___FOR_ZEND_minOccurs=0 ___FOR_ZEND_maxOccurs=1
         */
        public $Sistema;
        /**
         * @var dateTime ___FOR_ZEND_minOccurs=1 ___FOR_ZEND_maxOccurs=1
         */
        public $OraLogin;
        /**
         * @var dateTime ___FOR_ZEND_minOccurs=1 ___FOR_ZEND_maxOccurs=1
         */
        public $TimeOut;  
       
}
?>

That generate wsdl:

<xsd:complexType name="dateTime"><xsd:all/></xsd:complexType>
<xsd:complexType name="Ticket"><xsd:all>
<xsd:element name="Username" type="xsd:string" nillable="true" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Password" type="xsd:string" nillable="true" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Sistema" type="xsd:string" nillable="true" maxOccurs="1" minOccurs="0"/>
<xsd:element name="OraLogin" type="tns:dateTime" nillable="true" maxOccurs="1" minOccurs="1"/>
<xsd:element name="TimeOut" type="tns:dateTime" nillable="true" maxOccurs="1" minOccurs="1"/>
</xsd:all>
</xsd:complexType>

I don’t want nillable="true" and "tns:dateTime", I would nillable="false" where minOccurs is “1” and "xsd:dateTime".
I tried so:

<?php

class Ticket{
             /**
             * @var string ___FOR_ZEND_minOccurs=0 ___FOR_ZEND_maxOccurs=1
             */
             public $Username;
             /**
             * @var string ___FOR_ZEND_minOccurs=0 ___FOR_ZEND_maxOccurs=1
             */
        public $Password;
        /**
         * @var string ___FOR_ZEND_minOccurs=0 ___FOR_ZEND_maxOccurs=1
         */
        public $Sistema;
        /**
         * @xsd dateTime ___FOR_ZEND_minOccurs=1 ___FOR_ZEND_maxOccurs=1
         */
        public $OraLogin;
        /**
         * @xsd dateTime ___FOR_ZEND_minOccurs=1 ___FOR_ZEND_maxOccurs=1
         */
        public $TimeOut;  
       
}
?>

But the resulti is:

<xsd:complexType name="dateTime"><xsd:all/></xsd:complexType>
<xsd:complexType name="Ticket"><xsd:all>
<xsd:element name="Username" type="xsd:string" nillable="true" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Password" type="xsd:string" nillable="true" maxOccurs="1" minOccurs="0"/>
<xsd:element name="Sistema" type="xsd:string" nillable="true" maxOccurs="1" minOccurs="0"/>
</xsd:all>
</xsd:complexType>

That is, hide OraLogin and TimeOut parameters.

Thanks for reply