Returning Complex Objects

Help
Anonymous
2012-12-05
2013-06-06
  • Anonymous - 2012-12-05

    I'm just diving into NUSOAP and I'm having trouble with the nusoap server returning an array of objects
    Some of the code is below,

    $server->wsdl->addComplexType(
        'OrderRequest',
        'complexType',
        'struct',
        'all',
        '',
        array(
            'OrderID' => array('name'=>'OrderID','type'=>'xsd:int'),
            'Store' => array('name'=>'Store','type'=>'xsd:string')
        )
    );

    $server->wsdl->addComplexType(
        'Item',
        'complexType',
        'struct',
        'all',
        '',
        array(
            'LineNumber' => array('name'=>'LineNumber','type'=>'xsd:int'),
            'Quantity' => array('name'=>'Quantity','type'=>'xsd:string'),
            'Description' => array('name'=>'Description','type'=>'xsd:string')
        )
    );

    $server->wsdl->addComplexType(
        'List',
        'complexType',
        'struct',
        '',
        'SOAP-ENC:Array',
        array(),
        array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Item')
        ),
        'tns:Item'
    );

    $server->wsdl->addComplexType(
        'Items',
        'complexType',
        'struct',
        'all',
        '',
        array('List' => array('name' => 'List', 'type' =>'tns:List'))
    );

    $server->wsdl->addComplexType(
        'Order',
        'complexType',
        'struct',
        'all',
        '',
        array(
            'CompanyName' => array('name'=>'CompanyName','type'=>'xsd:string'),
            'ContactName' => array('name'=>'ContactName','type'=>'xsd:string'),
            'AddressLine1' => array('name'=>'AddressLine1','type'=>'xsd:string'),
            'AddressLine2' => array('name'=>'AddressLine2','type'=>'xsd:string'),
            'City' => array('name'=>'City','type'=>'xsd:string'),
            'State' => array('name'=>'State','type'=>'xsd:string'),
            'PostalCode' => array('name'=>'PostalCode','type'=>'xsd:string'),
            'Country' => array('name'=>'Country','type'=>'xsd:string'),
            'PhoneNumber' => array('name'=>'PhoneNumber','type'=>'xsd:string'),
            'Shipment' => array('name'=>'Shipment','type'=>'xsd:string'),
            'Items' => array('name'=>'Items','type'=>'tns:Items')       
        )
    );

    $server->register("pullOrder"                      
                     ,array('orderrequest'=>'tns:OrderRequest')
                     ,array('return' => 'tns:Order')
                     ,$namespace);

    It returns most of the object except the array of items is empty. I've double checked the array before it's being returned and it is populated. List is an array of Item Objects. If anyone has any suggestions please let me know.

    stdClass Object
    (
         =>
         => *********
         => *********
         =>
         => *********
         => *********
         => *********
         => *********
         => *********
         => Shipping
         => stdClass Object
            (
               

    • => Array
                      (
                      )

            )

    )

     
  • Anonymous - 2012-12-06

    For those of you who run into the following error with the latest nusoap libarary
    Object of class could not be converted to string nusoap.php on line 6133

    You need to go to nusoap.php line 6133 and comment out the line that says the following:
    $this->debug("serializing array element: $k, $v of type: $typeDef");

    I ran into this problem when I had it trying to return an array of objects.

    Thanks

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks