Is it possible to return a punch of data in NuSOAP in say XML format???
If it' what other way could I do it??
<?php
// Pull in the NuSOAP code
require_once('../nusoap/nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
// Register the method to expose
$server->register('hello', // method name
array('name' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello to the caller' // documentation
);
// Define the method as a PHP function
function hello($name) {
$server = "localhost"; // MySQL hostname
$username = "**"; // MySQL username
$password = "**"; // MySQL password
$dbname = "***"; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
//header('Content-type: application/xml');
// you need to return the error as xml as well
$res = mysql_query('SELECT * FROM members') or die('<error>'.mysql_error().'</error>');
$output[] = '<Users>';
while($row = mysql_fetch_assoc($res)){
$username = $row['username'];
$password = MD5($row['password']);
$level = $row['level'];
$email = $row['email'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$ID = $row['id'];
$username = str_replace("&", "", $username);
$output[] = "<User ID=\"$username\">";
$output[] = "<username>$username</username>";
$output[] = "<level>$level</level>";
$output[] = "<password>$password</password>";
$output[] = "<firstname><![CDATA[$firstname]]></firstname>";
$output[] = "<lastname><![CDATA[$lastname]]></lastname>";
$output[] = "<email><![CDATA[$email]]></email>";
$output[] = "<ID>$ID</ID>";
$output[] = '</User>';
}
$output[] = '</Users>';
return $output;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>