New to SOAP - Error occurs when connecting to MySQL?
Posted: Sun Sep 19, 2010 3:34 pm
Hi there, just joined these forums as I'm struggling to find an answer anywhere to my question.
I've just started learning SOAP so please don't shoot me down if it's something stupid I've missed.
Ok here's my SOAP server code:
Notice the 4 lines of mysql code currently commented out. The above code works fine and will return the array just fine to my client code however I am trying to access a database for sending my data. If I uncomment the 4 lines of mysql code I get the following error from the WSDL and I have no clue why? Can anyone help?
I've just started learning SOAP so please don't shoot me down if it's something stupid I've missed.
Ok here's my SOAP server code:
Code: Select all
<?php
//mysql_connect("localhost", "root", "*********") or die(mysql_error());
//mysql_select_db("mc") or die(mysql_error());
//$result = mysql_query("SELECT * FROM users WHERE id='1'") or die(mysql_error());
//$row = mysql_fetch_array( $result );
$quotes = array(
'IBM' => 98.20,
'GOOG' => 504.21
);
function getQuote($symbol) {
global $quotes;
return $quotes;
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("ptsoffice.wsdl");
$server->addFunction("getQuote");
$server->handle();
?>Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\ptsmc\soap\client1.php:5 Stack trace: #0 [internal function]: SoapClient->__call('getQuote', Array) #1 C:\wamp\www\ptsmc\soap\client1.php(5): SoapClient->getQuote() #2 {main} thrown in C:\wamp\www\ptsmc\soap\client1.php on line 5