我有一个简单的肥皂网服务,必须获得3个项目并将其插入表格。但只插入前两个字段。有什么问题?
这是服务器:
<?php
require_once '../scripts/database_connection.php';
require_once "lib/nusoap.php";
ini_set("soap.wsdl_cache_enabled", "1");
$server = new soap_server();
$server->configureWSDL("appstatus", "urn:appstatus");
$server->register('getStatus',
array("uid" => "xsd:decimal", "status" => "xsd:decimal", "comment" => "xsd:string"),
array("return" => "xsd:string"),
"urn:appstatus",
"urn:appstatus#getStatus",
"rpc",
"encoded",
"Get Status");
function getStatus($uid,$status,$comment) {
mysql_query('SET NAMES "utf8"');
$query="INSERT INTO a_test (uid, approved, comment) VALUES ('{$uid}','{$status}','{$comment}')";
mysql_query($query);
}
$server->service($HTTP_RAW_POST_DATA);
,这是客户:
<?php
require_once ('lib/nusoap.php');
ini_set("soap.wsdl_cache_enabled", "0");
//$result=$client->call('getStatus' array ('uid'=>3,'status'=>1));
$param = array( 'uid' => '33','status'=>'1','comment' => 'some comment');
$uid=$param['uid'];
$status=$param['status'];
$comment=$param['comment'];
$client = new nusoap_client('http://localhost/webservice/getstatus.php?wsdl');
$response = $client->call('getStatus',$param);
if($client->fault)
{
echo "FAULT: <p>Code: (".$client->faultcode."</p>";
echo "String: ".$client->faultstring;
}
else
{
echo 'OK';
}
?>
答案 0 :(得分:1)
SQL查询中有拼写错误,第三个参数不是变量:
$query="INSERT INTO a_test (uid, approved, comment) VALUES
('{$uid}','{$status}','comment')";
替换为:
$query="INSERT INTO a_test (uid, approved, comment) VALUES
('{$uid}','{$status}','{$comment}')";