Page 1 of 1

New to SOAP - Error occurs when connecting to MySQL?

Posted: Sun Sep 19, 2010 3:34 pm
by djlex1928
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. :P

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();
?>
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?
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

Re: New to SOAP - Error occurs when connecting to MySQL?

Posted: Sun Sep 19, 2010 4:53 pm
by Jonah Bron
Is that error from the calling script or the soap server you gave us? There's probably a SQL error going on.

Re: New to SOAP - Error occurs when connecting to MySQL?

Posted: Mon Sep 20, 2010 12:10 pm
by djlex1928
Sorry my fault, you did help. It was an error in the MySQL connection, really should of tested it on a basic php page first! lol :P