Help save net neutrality! Learn more.
Close

does nusoap support wsdl/xml sequence?

Help
Anonymous
2011-01-21
2013-06-06
  • Anonymous - 2011-01-21

    i have a type defined in wsdl that i need to return in a function GetResults

    <element name="Results">
        <complexType>
            <sequence maxOccurs="unbounded">
                <element name="Meter">
                    <complexType>
                        <attribute name="ID" type="string" use="required"/>
                        <choice minOccurs="0" maxOccurs="unbounded">
                            <element name="Register">
                                <complexType>
                                    <attribute name="ID" type="string" use="required"/>
                                    <attribute name="DateTime" type="dateTime" use="required"/>
                                    <attribute name="Value" type="string" use="required"/>
                                    <attribute name="Status" type="string" use="optional" default="0"/>
                                    <attribute name="Unit" type="string" use="optional" default=""/>
                                </complexType>
                            </element>
       ...
    

    here is the function which works

    function GetResults($parameter) {
        return
        array(
            "Meter" => array('ID' => '1', 'Register' => array('ID' => 1, 'DateTime' => 'dt', 'Value' => 12))
        );
    }
    

    but the problem is that i can only return one Meter which is not correct because i should be able to return array of meters.

    i've tried with

    function GetResults($parameter) {
        return
        array(
            array(
                "Meter" => array('ID' => '1', 'Register' => array('ID' => 1, 'DateTime' => 'dt', 'Value' => 12))
            ),
            array(
                "Meter" => array('ID' => '2', 'Register' => array('ID' => 1, 'DateTime' => 'dt', 'Value' => 12))
            )
        );
    }
    

    but it doesn't work

    any suggestions?

     
  • Scott Nichol

    Scott Nichol - 2011-01-21

    NuSOAP may have trouble with

           <sequence maxOccurs="unbounded">
                <element name="Meter">

    as opposed to something like

           <sequence>
                <element name="Meter" maxOccurs="unbounded">

    Specifically, a maxOccurs on an element is supported, but I don't think NuSOAP understands maxOccurs on a sequence.

    Beyond that, to return a doc/lit array try

    $meter =  array('ID' => '1', 'Register' => array('ID' => 1, 'DateTime' => 'dt', 'Value' => 12));
    $meter =  array('ID' => '2', 'Register' => array('ID' => 1, 'DateTime' => 'dt', 'Value' => 12));
    return array('Meter' => $meter);

     
  • Anonymous - 2011-01-21

    thanks, it works

     

Log in to post a comment.