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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.