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.
Code:
<?php
// ACARS SOAP FORMATTED METHODS
require "nusoap/nusoap.php";
$server = new soap_server;
$ns = "urn:fdxvaACARS";
$server->soap_defencoding = 'utf-8';
$server->configureWSDL('fdxvaACARS',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
$server->wsdl->addComplexType(
'Flight',
'complexType',
'struct',
'all',
'',
array(
'uID' => array('name'=>'uID','type'=>'xsd:string'),
'MID' => array('name'=>'MID','type'=>'xsd:string'),
'routeNum' => array('name'=>'routeID','type'=>'xsd:string'),
'origin' => array('name'=>'origin','type'=>'xsd:string'),
'destination' => array('name'=>'destination','type'=>'xsd:string'),
'depTime' => array('name'=>'depTime','type'=>'xsd:int'),
'acType' => array('name'=>'acType','type'=>'xsd:int'),
'flightType' => array('name'=>'flightType','type'=>'xsd:string'),
'note' => array('name'=>'note','type'=>'xsd:string'),
'flightPlan' => array('name'=>'flightPlan','type'=>'xsd:string'),
'oCharts' => array('name'=>'oCharts','type'=>'xsd:string'),
'oName' => array('name'=>'oName','type'=>'xsd:string'),
'oCity' => array('name'=>'oCity','type'=>'xsd:string'),
'oState' => array('name'=>'oSate','type'=>'xsd:string'),
'oCoor' => array('name'=>'oCoor','type'=>'xsd:string'),
'dCharts' => array('name'=>'dCharts','type'=>'xsd:string'),
'dName' => array('name'=>'dName','type'=>'xsd:string'),
'dCity' => array('name'=>'dCity','type'=>'xsd:string'),
'dState' => array('name'=>'dSate','type'=>'xsd:string'),
'dCoor' => array('name'=>'dCoor','type'=>'xsd:string'),
'aMake' => array('name'=>'aMake','type'=>'xsd:string'),
'aModel' => array('name'=>'aModel','type'=>'xsd:string')
)
);
$server->wsdl->addComplexType(
'Schedule',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Flight[]')
),
'tns:Flight'
); ////
$server->register(
'pilotSchedule',
array('pilotID'=>'xsd:string'),
array('return'=>'tns:Schedule'),
'fdxvaACARS',
'fdxvaACARS#pilotSchedule',
'rpc',
'encoded',
'Returns an array of scheduled flights.'
);
////
// DB CONNECTION
function connect(){
// CONNECT TO DB
if(mysql_connect("localhost","username","password")){}
else{ return false; }
if(mysql_select_db("database")){}
else{ return false; }
return true;
}
// GET ALL SCHEDULED FLIGHTS FOR A PILOT
function pilotSchedule($pilotID){
// SQL STRING
$sql = "SELECT s.uID,s.MID,s.routeNum,s.origin,s.destination,s.depTime,s.acType,s.flightType,
s.note,r.route AS flightPlan,o.charts AS oCharts, o.name AS oName, o.city AS oCity, o.state AS
oState, o.coor AS oCoor, d.charts AS dCharts, d.name AS dName, d.city AS dCity, d.state AS dState,
d.coor AS dCoor, a.make AS aMake, a.model AS aModel FROM scheduled AS s JOIN aircraft AS a
ON s.acType = a.ID LEFT OUTER JOIN routesSuggested AS r ON r.ID = s.routeNum LEFT OUTER JOIN
airports AS o ON o.ICAO = s.origin LEFT OUTER JOIN airports AS d ON d.ICAO = s.destination
WHERE s.MID = '" . $pilotID . "'";
// CONNECT TO DB
if(!connect()){
echo "Couldn't Connect";
}
// GET DATA
$result = mysql_query($sql);
$schedule = array();
while($flight = mysql_fetch_assoc($result)){
array_push($schedule,$flight);
}
return $schedule;
}
$request = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($request);
?>
Comment