php soap server/client

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheVillain9
    New Member
    • Sep 2006
    • 7

    php soap server/client

    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:


    the server is suppose to return back an array of an object called City, which has city code,name,count ry 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;
    	}
    }
    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('', '', '');
    		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();
    thanks for the help/suggestions or links you could provide.
Working...