我设法找到更多关于我的问题的信息并且我已经解决了。我在这里发布我的服务器代码,也许它也可以帮助其他人。
作为一个初学者,我已经尽可能地简化了代码。我的答案不包括配置文件,但如果有人需要它,请告诉我,我也会发布它。
我还要感谢所有在这个论坛上回答我的问题并帮助我理解我的错误的人。
<?php
include "conf.php";
require_once('nusoap/lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('This is my First nuSoapServer', 'urn:nuSoapServer');
$server->wsdl->addComplexType('Data',
'compexType',
'struct',
'all',
'',
array('id' => array('name' => 'id', 'type' => 'xsd:int'),
'acro' => array('name' => 'acro', 'type' => 'xsd:string'),
'time' => array('name' => 'time', 'type' => 'xsd:string'),
'date' => array('name' => 'date', 'type' => 'xsd:string'),
'note' => array('name' => 'note', 'type' => 'xsd:string'),
'prio' => array('name' => 'prio', 'type' => 'xsd:int'),
'data' => array('name' => 'data', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType(
'DataArray', // Name
'complexType', // Type Class
'array', // PHP Type
'', // Compositor
'SOAP-ENC:Array', // Restricted Base
array(), // Elements
array( // Atributes
array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:Data[]')
),
'tns:Data'
);
$server->register('GetTodoList', // method name
array('acro' => 'xsd:string'), // input parameters
array('DataResult' => 'tns:DataArray'), // output parameters
'urn:nuSoapServer', // namespace($namespace)
'urn:nuSoapServer#GetTodoList', // soap action
'rpc', // style
'encoded', // use
'Return Get to do list'); // documentation
function GetMyConnection() {
global $InputArray;
$dbase_link = mysql_connect($InputArray['host'],$InputArray['mysql_user'],$InputArray['mysql_password']);
//check if connected
if (!$dbase_link) {
die("Can not connect: " . mysql_error());
}
//return $this->myconn;
//http://se1.php.net/manual/en/function.mysql-create-db.php
$dbase_select = mysql_select_db($InputArray['mysql_dbase']);
if (empty($dbase_select)) {
$sql = "CREATE DATABASE IF NOT EXISTS ".$InputArray['mysql_dbase']."\n";
if (mysql_query($sql)) {
echo "Database: " . $InputArray['mysql_dbase'] . " was created succesfully\n";
}
else {
echo "Error creating database: " . mysql_error() . "\n";
}
}
$dbase_select = mysql_select_db($InputArray['mysql_dbase']);
$sql = "CREATE TABLE IF NOT EXISTS ".$InputArray['mysql_dbase_table']." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`acro` varchar(25) NOT NULL,
`time` varchar(25) NOT NULL,
`date` varchar(25) NOT NULL,
`note` varchar(1024) NOT NULL,
`prio` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
$create = mysql_query($sql);
if (!$create) {
echo "Error creating table: " . mysql_error() . "\n";
}
}// End of Function GetMyConnection
function closeConnection() {
$terminate = mysql_close();
if ($terminate) {
echo "Connection terminated\n";
}
else {
echo "Error terminating connection: " . mysql_error() . "\n";
}
}//End of function closeConnection
// create the function
function GetTodoList($acro) {
global $InputArray;
GetMyConnection();
if (!$acro) {
return new soap_fault('Client', '', 'No data received!');
}
else {
$dbase_select = mysql_select_db($InputArray['mysql_dbase']);
$get = mysql_query("SELECT * FROM " . $InputArray['mysql_dbase_table'] . " WHERE `acro` = '" . $acro . "'");
if($get === FALSE) {
echo "Could not retrieve data from: " . $InputArray['mysql_dbase_table'] . " due to: " . mysql_error() . "\n";
}
else {
while($total = mysql_fetch_array($get)) {
$Data[] = array('id' => $total['id'],
'acro' => $total['acro'],
'time' => $total['time'],
'date' => $total['date'],
'note' => $total['note'],
'prio' => $total['prio']);
}
}
}
return $Data;
closeConnection();
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
exit();
?>