problems with web services
Posted: Sun Aug 16, 2009 7:30 am
For my final work, I need to do online shop over web services. The thing that I can't do is to show values from database when I return them with array. I have found some code over the internet but it return empty array. Can somebody help me?
My code in web service is:
***** Please wrap PHP code with the Code tag (see buttons at top of editor) *****
My code in web service is:
***** Please wrap PHP code with the Code tag (see buttons at top of editor) *****
Code: Select all
require_once('C:\wamp\www\seminarskiIteh\lib\nusoap.php');
$connect = mysql_connect("localhost", "root", "") or
die ("Neuspesna konekcija sa bazom podataka");
mysql_select_db("seminarski");
$server = new soap_server();
$server -> configureWSDL('webservis', 'urn:webservis');
$server->wsdl->addComplexType(
'Proizvod',
'complexType',
'struct',
'all',
'',
array(
'ID' => array('name'=>'ID','type'=>'xsd:int'),
'naziv' => array('name'=>'naziv','type'=>'xsd:string'),
'opis' => array('name'=>'opis','type'=>'xsd:string'),
'cena' => array('name'=>'cena','type'=>'xsd:float'),
'kolicina' => array('name'=>'kolicina','type'=>'xsd:int')
)
);
$server->wsdl->addComplexType(
'NizProizvoda',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Proizvod[]')
),
'tns:Proizvod'
);
$server->register('izmeniProizvode', array(),
array('return' => 'tns:NizProizvoda'),
'urn:izmeniProizvode'
);
I just wrote that function izmeniProizvode because the others works...
function izmeniProizvode(){
$query="SELECT ID,naziv FROM proizvod WHERE kategorija='sofe' ";
$result=mysql_query($query)
or die(mysql_error());
$kolona=mysql_num_rows($result);
if ($kolona>0){
while ($row = mysql_fetch_array($result)) {
$niz[]=array('ID'=>$row['ID'],
'naziv'=>$row['naziv']
);
}
}
return $niz;
}