0
我有一個簡單的soap web服務,它必須獲取3個項目並將它們插入到表中。但只有前兩個字段被插入。哪裏不對?並非所有字段都插入到MySQL表中
這裏的服務器:
<?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';
}
?>
對不起大家,一切都很好!編碼時要注意;)我重命名文件,但不斷編輯其以前的版本。 – Alex