NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
array of arrays


Joined: 25 Oct 2005
Posts: 5
Reply with quote
Hi

In my nusoap server I have specified the following outgoing array:

Code:
$server->wsdl->addComplexType(
    'cats_parsout',
    'complexType',
    'struct',
    'all',
    '',
    array(       
        'catID' => array('name'=>'catID','type'=>'xsd:string'),
        'parent' => array('name'=>'parent','type'=>'xsd:string'),
        'catName' => array('name'=>'catName','type'=>'xsd:string'),       
        'description' => array('name'=>'description','type'=>'xsd:string'),       
        'cat_ref' => array('name'=>'cat_ref','type'=>'xsd:string'),
        'list_order' => array('name'=>'list_order','type'=>'xsd:string'),
        'webVisible' => array('name'=>'webVisible','type'=>'xsd:string'),
        'subcat' => array('name'=>'subcat','type'=>'xsd:string')       
    )
);


The only problem is that 'subcat' is not a string but an array of 'cats_parsout'.
How can I specify that 'subcat' is
1) of type array
2) Is an array of 'cats_parsout'?

I know that there is no such type as xsd:array and do not know what the work around is
View user's profileFind all posts by mr_cheSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
look at examples posted on this forum.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 25 Oct 2005
Posts: 5
Reply with quote
I have, but there are no posts that give any explanation to my problem:

e.g.

Code:
$server = new soap_server;
$server->debug_flag=true;  // TURN ON DEBUGGING
$server->configureWSDL('categories_server', 'urn:categories_server');
$server->wsdl->schemaTargetNamespace = $servicePath;

$server->wsdl->addComplexType(
    'cats_parsIn',
    'complexType',
    'struct',
    'all',
    '',
    array(
        'customer_db' => array('name'=>'customer_db','type'=>'xsd:string'),
        'websiteID' => array('name'=>'websiteID','type'=>'xsd:string'),       
        'catID' => array('name'=>'catID','type'=>'xsd:string'),
        'parent' => array('name'=>'parent','type'=>'xsd:string'),
        'catName' => array('name'=>'catName','type'=>'xsd:string'),
        'description' => array('name'=>'description','type'=>'xsd:string'),
        'cat_ref' => array('name'=>'cat_ref','type'=>'xsd:string'),
        'list_order' => array('name'=>'list_order','type'=>'xsd:string'),
        'webVisible' => array('name'=>'webVisible','type'=>'xsd:string')   
    )         
);

$server->wsdl->addComplexType(
    'cats_parsout',
    'complexType',
    'struct',
    'all',
    '',
    array(       
        'catID' => array('name'=>'catID','type'=>'xsd:string'),
        'parent' => array('name'=>'parent','type'=>'xsd:string'),
        'catName' => array('name'=>'catName','type'=>'xsd:string'),       
        'description' => array('name'=>'description','type'=>'xsd:string'),       
        'cat_ref' => array('name'=>'cat_ref','type'=>'xsd:string'),
        'list_order' => array('name'=>'list_order','type'=>'xsd:string'),
        'webVisible' => array('name'=>'webVisible','type'=>'xsd:string'),
        'subcat' => array('name'=>'subcat','type'=>'xsd:string[]', 'maxOccurs'=>'unbounded')               
    )
);


$server->wsdl->addComplexType(
    'parsout_Array',
    'complexType',
    'array',
    '',
    'SOAP-ENC:Array',
    array(),
    array(
        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:cats_parsout[]')
   ),
  'tns:cats_parsout'
);


// INITIATE THE SOAP SERVER AND DEFINE THE SETTINGS
$server->register('get_categories',
array('cats_parsIn'=>'tns:cats_parsIn'),   // input parameters
array('return'=> 'tns:parsout_Array'),   // output parameters array
'urn:categories_server',      // namespace
'urn:categories_server#get_categories',   // soapaction
'rpc',            // style
'encoded',                                      // use
'Categories Service'         // documentation
);


When I return the data, I get the follwoing:

Code:
_categories => (
   0 => (
      catID => '3'
      parent => '0'
      catName => 'furniture'
      description => 'including wicker chairs, pine tables, cabinets, leather sofas'
      cat_ref => 'furn'
      list_order => '1'
      webVisible => 'yes'
      subcat => (
         0 => 'Array'
         1 => 'Array'
         2 => 'Array'
         3 => 'Array'
         4 => 'Array'
         5 => 'Array'
      )
   )


subcat should be a repeat of 'cats_parsout' showing subcats, but just get 'Array' returned.
Not sure if im explaining my problem well.
View user's profileFind all posts by mr_cheSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7901
Reply with quote
I think you'd take a look at the samples first
For example:
return-an-array-of-structs-from-server-t2107.html

hope it helps.
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 25 Oct 2005
Posts: 5
Reply with quote
Hi

No that isn't what I am trying to achieve.
I want to return a list of website categories, but I also want to return all the catgeories sub categories and display them in relation.



I want to return a nested array back from my soap service. All other examples are just returning one dimensional arrays.
I want the 'subcats' element to be an array of "cats_parsout".
I have specified the following complexTypes.


Code:
$server->wsdl->addComplexType(
  'cats_parsout',
  'complexType',
  'struct',
  'all',
  '',
  array(       
     'catID' => array('name'=>'catID','type'=>'xsd:string'),
     'parent' => array('name'=>'parent','type'=>'xsd:string'),
     'catName' => array('name'=>'catName','type'=>'xsd:string'),       
     'descrip' => array('name'=>'descrip','type'=>'xsd:string'),       
     'cat_ref' => array('name'=>'cat_ref','type'=>'xsd:string'),
     'list_order' => array('name'=>'list_order','type'=>'xsd:string'),
     'webVis' => array('name'=>'webVis','type'=>'xsd:string'),       
     'subcats' => array('name'=>subcats','type'=>'xsd:string[]')         
    )
);
 

$server->wsdl->addComplexType(
  'parsout_Array',
  'complexType',
  'array',
  '',
  'SOAP-ENC:Array',
  array(),
  array(
    array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:cats_parsout[]')
  ),
  'tns:cats_parsout'
);


All the elements are successfully returned apart from the 'subcats' element which is always blank or the string'Array' is returned if I specify the 'subcats' elements as followed:

'subcats' => array('name'=>subcats','type'=>'xsd:string[]', 'maxOccurs'=>'unbounded')


Does anybody know where I am going wrong?
'subcats' seems to be returned as a string as far as I can tell, and seeing as there is no such thing as a 'type'=>'xsd:array', how can I specify the 'subcats' elements as an array??
View user's profileFind all posts by mr_cheSend private message


Joined: 21 Apr 2008
Posts: 10
Reply with quote
Hi,

Oops, I think I am not too late in helping you.

Just have a look to this url error-retrieving-data-from-nusoap-webservice-t3091.html.

Regards,

Dave
View user's profileFind all posts by naimish_hitSend private message
array of arrays
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic