Ok, I've got a soap client and have a function in it called buidall.
It is called from one script like this:
//
// rest of script does database updates
// the buildall function in the soapclient
// builds an XML file to be used in a Flash scroller
//
$client_ticker = new SoapClient(null,array('location' =>"./server_ticker.php",'uri' => "urn://eddie/res"));
$client_ticker->buildall(array($_POST["gamenum"]));
Here is the error I am getting:
Fatal error: Uncaught SoapFault exception: [HTTP]
Unable to parse URL in C:\wamp\www\2005\storegame.php:67
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'server_ticker.p...', 'urn://eddie/req...', 1, 0)
#1 C:\wamp\www\2005\storegame.php(67): SoapClient->__soapCall('buildall', Array)
#2 {main} thrown in C:\wamp\www\2005\storegame.php on line 67
I can not understand how the '<?xml version="...' gets put in the __doRequest call.
Here is the abbreviated server_ticker.php source.
<?php
define ("NL", "\n");
function fixit(&$item, $key) {
// This function gets info from the DB and computes
// the team's wins, losses, and ties then returns
// the results.
$item['vwins'] = $vwins;
$item['vloss'] = $vloss;
$item['vties'] = $vties;
mysql_free_result($records);
} // fixit
function buildit($div) {
include("/home/crnorth/dbutil/dbconnect.inc");
mysql_connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
// we have different divisons to keep track of
switch ($div) {
case "AA":
$divname = "AA";
break;
case "C":
$divname = "Continental";
break;
case "N":
$divname = "National";
break;
case "A":
$divname = "American";
break;
case "BR":
$divname = "Babe Ruth";
break;
}
global $wk;
global $useSimpleXML;
global $xml;
$sql = '';
// Gets game data from the db for the week.
$sql = $sql.'select g.gamenum,';
<snip sql code>
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$id = array_shift($row);
$array1[$id] = $row;
}
// use fixit callback to "compute" the results correctly
array_walk($array1, 'fixit');
// add the name node
if ($useSimpleXML) {
$data = $xml->xpath('//data');
$div = $data[0]->addChild('division');
$div->addAttribute('name', $divname);
}
// now, build the data node from the array returned from the fixit function
foreach($array1 as $k => $array2) {
<snip code to build the data node>
}
if ($useSimpleXML) {
file_put_contents("gamedata.xml", $xml->asXML());
} else {
$xml = "\t\t<division name=\"$divname\">\n".$xml."\t\t</division>".NL;
$fp = fopen("gamedata.xml", "a");
fwrite($fp, $xml);
fclose($fp);
}
}
mysql_free_result($result);
mysql_close;
}
function buildall($game) {
$wk = 0;
$useSimpleXML = true;
include("/home/crnorth/dbutil/dbconnect.inc");
mysql_connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
$sql = $sql.'select WEEK(gamedate) from games WHERE gamenum = '.$game;
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
list($wk)=mysql_fetch_row($result);
}
mysql_close;
if (!$useSimpleXML) {
$fp = fopen("gamedata.xml", "w");
$hdr = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>\n\t<data>\n";
fwrite($fp, $hdr);
fclose($fp);
}
buildit("AA");
buildit("C");
buildit("N");
buildit("A");
buildit("BR");
if (!$useSimpleXML) {
$fp = fopen("gamedata.xml", "a");
fwrite($fp, "\n\t</data>");
fclose($fp);
}
}
$server = new SoapServer(null, array('uri' => "urn://eddie/res"));
$server->addFunction('buildall');
$server->handle();
?>