Jump to content

problems with web services


simona_85

Recommended Posts

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:

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;

}

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/170500-problems-with-web-services/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.