Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOtherTutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old October 24th, 2005, 08:53 AM
Payne Payne is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 8 Payne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
nuSoap

I am quite a newbie in php but am trying to create a web service that returns multiple arrays of data. However, I got stuck on the client side. Basically, i'd simply like to manage to create a client php script with nusoap which can extract and display the returned array. Below is the server side code. Any guru out there who can help me out please?

Thanks

php Code:
Original - php Code
  1.  
  2. <?php
  3.        
  4.     // includes nusoap classes
  5.     require('nusoap.php');
  6.    
  7.     // create server
  8.     $l_oServer = new soap_server();
  9.  
  10.     // wsdl generation
  11.     $l_oServer->debug_flag=false;
  12.     $l_oServer->configureWSDL('TvData', 'http://fakeabctv.org/schedule');
  13.     $l_oServer->wsdl->schemaTargetNamespace = 'http://fakeabctv.org/schedule';
  14.  
  15.     // add complex type
  16.     $l_oServer->wsdl->addComplexType(
  17.         'scheduleitem',
  18.         'complexType',
  19.         'struct',
  20.         'all',
  21.         '',
  22.         array(
  23.             'name' => array('name'=>'name', 'type'=>'xsd:string'),
  24.             'start' => array('name'=>'start', 'type'=>'xsd:string'),
  25.             'end' => array('name'=>'end', 'type'=>'xsd:string'))
  26.     );
  27.    
  28.     $l_oServer->wsdl->addComplexType(
  29.         'dailyschedule',
  30.         'complexType',
  31.         'array',
  32.         '',
  33.         'SOAP-ENC:Array',
  34.         array(),
  35.         array(
  36.             array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:scheduleitem[]')
  37.         ),
  38.         'tns:scheduleitem'
  39.     );
  40.  
  41.     // register method
  42.     $l_oServer->register('getSchedule', array(
  43.         'date' => 'xsd:string'),
  44.             array('return'=>'tns:dailyschedule'),
  45.                 'http://fakeabctv.org/schedule');
  46.  
  47.     // method code (get DB result)
  48.     function getSchedule ($a_stInput) {
  49.         if (is_string($a_stInput)) {   
  50.             $l_oDBlink   = @mysql_connect(
  51.                 'localhost', 'root', 'root');
  52.             $l_oDBresult = @mysql_db_query(
  53.                 'tvdb',
  54.                 'SELECT item.name, slot.start, slot.end FROM (episode INNER JOIN item ON episode.itemID = item.itemID) INNER JOIN slot ON episode.episodeID = slot.episodeID
  55.                 WHERE slot.date = ("' . mysql_escape_string((string)$a_stInput) . '")');
  56.                
  57.             // simple error checking
  58.             if (!$l_oDBresult) {
  59.                 return new soap_fault('Server', '', 'Internal server error.');
  60.             }
  61.      
  62.             // no data avaible for x city
  63.             if (!mysql_num_rows($l_oDBresult)) {
  64.                 return new soap_fault('Server', '',
  65.                     'Service contains data only for a few cities.');
  66.             }
  67.             mysql_close($l_oDBlink);
  68.          
  69.             // return data
  70.             $scheduleitem = array();
  71.            
  72.                         
  73.                         for ( $counter = 0;
  74.                     $list = mysql_fetch_object( $l_oDBresult);
  75.                     $counter++ )
  76.                 {
  77.            
  78.                 $itemname = $list -> name;
  79.                 $start = $list -> start;
  80.                 $end = $list -> end;
  81.                
  82.                        // build table to display results
  83.           
  84.                     $scheduleitem[] = array('name' => $itemname, 'start' => $start, 'end' => $end);
  85.                         
  86.                     }
  87.        
  88.         $schedule = array('scheduleitem' => $scheduleitem);
  89.                 return $schedule;   
  90.         }
  91.         // we accept only a string
  92.         else {
  93.           return new soap_fault('Client', '', 'Service requires a string parameter.');
  94.         }
  95.       }
  96.  
  97.     // pass incoming (posted) data
  98.     $l_oServer->service($HTTP_RAW_POST_DATA);
  99. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOtherTutorials > nuSoap


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway