Jump to content

php soap server/client


TheVillain9

Recommended Posts

i'm working on a php soap server. i'm not entirely sure if my problem is with the server or just if i need to do something else on the client side.

basically i created a sample client at:
http://67.96.115.172/dev/client.php

the server is suppose to return back an array of an object called City, which has city code,name,country and country_code. on the client when i try to iterate through the array i am doing...

[code]$client = new SoapClient("http://67.96.115.172/dev/soap/TeamAmerica.wsdl");
$cities = $client->getCitiesByCountry("US");
echo "<BR>".count($cities)." cities found";

if(is_array($cities)) {
foreach($cities as $city) {
echo "\n<BR>".$city->City->city_code."cn:".$city->city_name;
}
}[/code]

but that prints nothing!

my server is:

[code]ini = ini_set("soap.wsdl_cache_enabled","0");

class City {
var $city_code;
var $city_name;
var $country_code;
var $country_name;
function City($citycode,$cityname,$countryname,$countrycode  ) {
$this->city_code=$citycode;
$this->city_name=$cityname;
$this->country_name=$countryname;
$this->country_code=$countrycode;
}
}


class SoapService {
function getCitiesByCountry($country_code)
{
$cities = array();
$db = mysql_connect('', '', ''); // left blank on purpose
mysql_select_db('dev_db', $db);
$sql = "SELECT * FROM tblCity WHERE country_code='".$country_code."'";
$city = mysql_query("SELECT * FROM tblCity WHERE country_code='".$country_code."'", $db);
while($row = mysql_fetch_object($city))
{ $cities[] = new City($row->CityCode,$row->CityName,$row->country,$country_code);
}
mysql_close($db);
return $cities;
}
}

$classmap = array('City' => 'City');
$server = new SoapServer("http://67.96.115.172/dev/soap/TeamAmerica.wsdl",array('classmap'=> $classmap));
$server->setClass("SoapService");
$server->handle();[/code]

the wsdl file is [url=http://67.96.115.172/dev/soap/TeamAmerica.wsdl]http://67.96.115.172/dev/soap/TeamAmerica.wsdl[/url]

thanks for the help. ???
Link to comment
https://forums.phpfreaks.com/topic/32050-php-soap-serverclient/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.