Joined: 20 Mar 2008 |
Posts: 1 |
|
|
|
Posted: Wed Mar 19, 2008 5:25 am |
|
|
|
|
|
I have the same problem....in output i have unable to serialize result...
service code:
<?php
include('include/boot.php');
// server
$l_oServer = new soap_server();
// generazione del wsdl
$l_oServer->debug_flag=false;
$namespace = 'http://www.user.org/User';
$l_oServer->configureWSDL('User', $namespace);
$l_oServer->wsdl->schemaTargetNamespace = $namespace;
$l_oServer->wsdl->addComplexType(
'UserData',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:User[]')
),
'tns:User'
);
$l_oServer->register('getUser',
array('user' => 'xsd:string'),
array ('return'=>'tns:UserData'),
$namespace, // namespace
$namespace . '#getUser', // soapaction
'rpc', // style
'encoded', // use
'Get Specific User' // documentation
);
// metodo recupero dati
function getUser ($a_stInput) {
//istanzio la classe che setta l'applicazione
$istance = Site::getInstance();
//Setto l'oggetto sessione
//SessionObject::getInstance()->set('site', $istance);
//istanzio il db
$db = $istance->getDB();
if (is_string($a_stInput)) {
$data = $db->sendQuery("select Nome from TipiStep");
$retval = $data['records'];
//print_r($retval);
return $retval;
}else{
return new soap_fault('Client', '', 'Service requires a string parameter.');
}
}
// pass incoming (posted) data
//$HTTP_RAW_POST_DATA = "user";
$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$l_oServer->service($HTTP_RAW_POST_DATA);
?>
The client code is:
<?php
if(isset($_GET)){
if(!isset($_GET['action'])){
$_GET['action'] = "";
}elseif($_GET['action'] == 'get_data') {
// set parameters and create client
$l_aParam = array((string)$_POST['user']);
$l_oClient = new soapclient('http://127.0.0.1/server/service.php');
$l_stResult = $l_oClient->call('getUser', $l_aParam);
$data = $l_stResult;
//$dump->dump($l_stResult);
//$debug = $l_oClient->debug_str;
//echo"<br>";
//echo"debug".$debug."";
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($l_oClient->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($l_oClient->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($l_oClient->debug_str, ENT_QUOTES) . '</pre>';
// errori
if (!$l_oClient->getError()) {
// print results
/* print_r($data);*/
/* print'<h1>Current data for: ' . $l_aParam[0]
. ':</h1><ul><li>NAME: ' . $l_stResult['ID_TipoStep']
. '</li><li>Email: ' . $l_stResult['Nome']
. '</li></ul>';
*/
}
else {
$data ='<h1>Error: ' . $l_oClient->getError() . '</h1>';
}
}
}
if(isset($data)){
$smarty->assign('DATA', $data);
}
$smarty->display($pageToShow['tpl_dir']);
?>
can you help me?Thanks
|