By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,559 Members | 1,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,559 IT Pros & Developers. It's quick & easy.

SOLVED: nuSOAP returns empty object

P: 33
Hello, I have very little knowledge when it comes to SOAP, but a developer I'm working with says it will make things easier when passing data to/from client software and the mySQL database. Anyhow, I created this SOAP server per examples and instructions on various websites, and the server appears to be functioning (Server). However, the client software developer says they are getting the "Schedule" object back empty, regardless of what argument they pass to the pilotSchedule method. I have no way to check their code, so I have to assume it's correct. Can someone with SOAP experience take a look for an error here? Below is the server markup.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     // ACARS SOAP FORMATTED METHODS 
  4.  
  5.     require "nusoap/nusoap.php";                                                                             
  6.  
  7.     $server = new soap_server;                                                                               
  8.     $ns = "urn:fdxvaACARS";                                                                                  
  9.     $server->soap_defencoding = 'utf-8';                                                                     
  10.     $server->configureWSDL('fdxvaACARS',$ns);                                                                
  11.     $server->wsdl->schemaTargetNamespace=$ns;                                                                
  12.     $server->wsdl->addComplexType(                                                                           
  13.         'Flight',                                                                                            
  14.         'complexType',                                                                                       
  15.         'struct',                                                                                            
  16.         'all',                                                                                               
  17.         '',                                                                                                  
  18.         array(                                                                                               
  19.             'uID'           =>  array('name'=>'uID','type'=>'xsd:string'),                                   
  20.             'MID'           =>  array('name'=>'MID','type'=>'xsd:string'),                                   
  21.             'routeNum'      =>  array('name'=>'routeID','type'=>'xsd:string'),                               
  22.             'origin'        =>  array('name'=>'origin','type'=>'xsd:string'),                                
  23.             'destination'   =>  array('name'=>'destination','type'=>'xsd:string'),                           
  24.             'depTime'       =>  array('name'=>'depTime','type'=>'xsd:int'),                                  
  25.             'acType'        =>  array('name'=>'acType','type'=>'xsd:int'),                                   
  26.             'flightType'    =>  array('name'=>'flightType','type'=>'xsd:string'),                            
  27.             'note'          =>  array('name'=>'note','type'=>'xsd:string'),                                  
  28.             'flightPlan'    =>  array('name'=>'flightPlan','type'=>'xsd:string'),                            
  29.             'oCharts'       =>  array('name'=>'oCharts','type'=>'xsd:string'),                               
  30.             'oName'         =>  array('name'=>'oName','type'=>'xsd:string'),                                 
  31.             'oCity'         =>  array('name'=>'oCity','type'=>'xsd:string'),                                 
  32.             'oState'        =>  array('name'=>'oSate','type'=>'xsd:string'),                                 
  33.             'oCoor'         =>  array('name'=>'oCoor','type'=>'xsd:string'),                                 
  34.             'dCharts'       =>  array('name'=>'dCharts','type'=>'xsd:string'),                               
  35.             'dName'         =>  array('name'=>'dName','type'=>'xsd:string'),                                 
  36.             'dCity'         =>  array('name'=>'dCity','type'=>'xsd:string'),                                 
  37.             'dState'        =>  array('name'=>'dSate','type'=>'xsd:string'),                                 
  38.             'dCoor'         =>  array('name'=>'dCoor','type'=>'xsd:string'),                                 
  39.             'aMake'         =>  array('name'=>'aMake','type'=>'xsd:string'),                                 
  40.             'aModel'        =>  array('name'=>'aModel','type'=>'xsd:string')                                 
  41.         )                                                                                                    
  42.     );                                                                                                       
  43.     $server->wsdl->addComplexType(                                                                           
  44.         'Schedule',                                                                                          
  45.         'complexType',                                                                                       
  46.         'array',                                                                                             
  47.         '',                                                                                                  
  48.         'SOAP-ENC:Array',                                                                                    
  49.         array(),                                                                                             
  50.         array(                                                                                               
  51.             array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Flight[]')                              
  52.         ),
  53.         'tns:Flight'                                                                                         
  54.     );                                                                                                                                                                                                             ////
  55.     $server->register(                                                                                       
  56.         'pilotSchedule',                                                                                     
  57.         array('pilotID'=>'xsd:string'),                                                                      
  58.         array('return'=>'tns:Schedule'),                                                                     
  59.         'fdxvaACARS',                                                                                        
  60.         'fdxvaACARS#pilotSchedule',                                                                          
  61.         'rpc',                                                                                               
  62.         'encoded',                                                                                           
  63.         'Returns an array of scheduled flights.'                                                             
  64.     );                                                                                                       
  65.                                                                                                                                                                                                                     ////
  66.  
  67.     // DB CONNECTION                                                                                         
  68.     function connect(){                                                                                      
  69.  
  70.       // CONNECT TO DB                                                                                       
  71.       if(mysql_connect("localhost","username","password")){}                   
  72.       else{ return false; }                                                                                  
  73.       if(mysql_select_db("database")){}                                          
  74.       else{ return false; }                                                                                  
  75.  
  76.       return true;                                                                                           
  77.  
  78.     }                                                                                                        
  79.  
  80.  
  81.  
  82.     // GET ALL SCHEDULED FLIGHTS FOR A PILOT  
  83.     function pilotSchedule($pilotID){
  84.  
  85.         // SQL STRING
  86.         $sql =  "SELECT s.uID,s.MID,s.routeNum,s.origin,s.destination,s.depTime,s.acType,s.flightType,
  87.                 s.note,r.route AS flightPlan,o.charts AS oCharts, o.name AS oName, o.city AS oCity, o.state AS 
  88.                 oState, o.coor AS oCoor, d.charts AS dCharts, d.name AS dName, d.city AS dCity, d.state AS dState, 
  89.                 d.coor AS dCoor, a.make AS aMake, a.model AS aModel FROM scheduled AS s JOIN aircraft AS a 
  90.                 ON s.acType = a.ID LEFT OUTER JOIN routesSuggested AS r ON r.ID = s.routeNum LEFT OUTER JOIN 
  91.                 airports AS o ON o.ICAO = s.origin LEFT OUTER JOIN airports AS d ON d.ICAO = s.destination
  92.                 WHERE s.MID = '" . $pilotID . "'";    
  93.  
  94.         // CONNECT TO DB
  95.         if(!connect()){
  96.           echo "Couldn't Connect";
  97.         } 
  98.  
  99.         // GET DATA
  100.         $result = mysql_query($sql);      
  101.         $schedule = array();
  102.  
  103.         while($flight = mysql_fetch_assoc($result)){
  104.             array_push($schedule,$flight);
  105.         }
  106.  
  107.         return $schedule;
  108.  
  109.     }
  110.  
  111.  
  112.  
  113.     $request = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';                                        
  114.     $server->service($request);                                                                              
  115.  
  116. ?>
Dec 14 '09 #1
Share this Question
Share on Google+
2 Replies


P: 33
Client software developer got it to bring in filled arrays, sorry for post.
Dec 14 '09 #2

P: 1
Did the developer say how he solved the problem? I'm having the same issue now with both a NuSOAP client and from SoapUI.
Dec 21 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.