PHP SOAP returning wrong values to clients
I'm trying to return a value from my (MySQL) database to a C# client, through SOAP.
The server is written in PHP, which I think is where everything goes wrong:
class foo{
function bar()
{
$result = $connection->query("SELECT value
FROM table
WHERE id='$id'");
$row = $result->fetch_assoc();
return (int)$row['value'];
}
}
Will turn up as 0 in C#, no matter what value was in the database. However,
class foo{
function bar()
{
return 5;
}
}
turns up as the correct value (5 in this case) in C#.
What am I missing here? It seems that data from the database will not be returned to C# correctly, but any other ways of writing the same value (statically) in PHP, will succeed.
EDIT: I've now set up a PHP SOAP-client, which receives the same values as C# does. So it seems that the problem is with the PHP SOAP-server, communicating the wrong values to the client (whenever the value to return is not static).
EDIT: I have now found the solution to my problem; My WSDL file had a complex request type, even though it only required a simple type. Changing this co开发者_StackOverflow中文版mplex type to a simple type, fixed the problem. Do not ask me why - it does not make the slightest sense to me!
You are asking for an associative array. This may return more that one item.
精彩评论