2016-03-22 32 views
0

Kişisel web hizmeti nusoap bir proje üzerinde çalışıyorum web hizmeti üzerinden geçen hafta web hizmeti ilk kez başladım.Karmaşık bir tür oluşturun nusoap php

Şu anda bir tablo şeklinde bir öğe ekleyen bir web hizmeti yazma çalışıyorum.

require_once ('lib/nusoap.php'); 
$server = new nusoap_server(); 

$server->configureWSDL("test", "urn:Test/", "http://localhost/testajout/server.php"); 
    $server->wsdl->schemaTargetNamespace="http://localhost/testajout/server.php"; 
$server->soap_defencoding = 'utf-8'; 
//register of method 
$server->wsdl->addComplexType(
    'cordonne', 
    'complexType', 
    'struct', 
    'all', 
    '', 
    array(
      'ID'=> array('name' => 'id', 'type' => 'xsd:int'), 
      'prenom'=> array('name' => 'prenom', 'type' => 'xsd:string'), 
      'lastname'=> array('name' => 'lastname', 'type' => 'xsd:string'), 
      'datedebut'=> array('name' => 'datedebut', 'type' => 'xsd:date'), 
      'solde'=> array('name' => 'solde', 'type' => 'xsd:decimal'), 
      'identifient'=> array('name' => 'identifient', 'type' => 'xsd:string'), 
      'photo' => array('name' => 'photo', 'type' => 'xsd:string'), 
      'fid'=> array('name' => 'fid', 'type' => 'xsd:int'), 
      'codebarre' => array('name' => 'codebarre', 'type' => 'xsd:string') 
     )); 
$server->register('InsertUser',array('cordonne'=>'tns:cordonne'),array('return' =>'xsd:string')); 
function InsertUser($cordonne){ 
     $cordonne=array(); 
     $db1=new PDO('mysql:host=localhost;dbname=service','root',''); 
     /* $req1 = $db1->prepare("SELECT * FROM myusers WHERE identifient =:identifient"); 
     $req1->execute(array(':identifient' =>$identifient)); 
     $count = $req1->rowCount(); 
     if($count){ 
      return "existe déja"; 
     }else{*/ 
     $id=$cordonne['id']; 
     $prenom = $cordonne['nom']; 
     $lastname = $cordonne['prenom']; 
     $datedebut = $cordonne['datedebut']; 
     $solde = $cordonne['solde']; 
     $login = $cordonne['identifient']; 
     $photo =$cordonne['photo']; 
     $fid=$cordonne['fid']; 
     $codebarre=$cordonne['codebarre']; 

       $req=$db1->prepare("insert into myusers values(:ID,:Prenom,:LastName,:dateDebut,:solde,:identifient,:photo,:fidelit,:CodeBarre)"); 
       $req->execute(array(':ID'=>$id,':Prenom'=>$prenom,':LastName'=>$lastname,':dateDebut'=>date("Y-m-d", strtotime($datedebut)),':solde'=>$solde, 
           ':identifient'=>$login,':photo'=>$photo,':fidélit'=>$fid,':CodeBarre'=>$codebarre)); 
     return "client ajouter"; 


} 

Müşteri kodu:

error_reporting(E_ALL); 
    // Pull in the NuSOAP code 
    require_once('lib/nusoap.php'); 
    // Create the client instance 
    $client = new nusoap_client('http://localhost/testajout/server.php'); 
$cordonne['id']=NULL; 
    $cordonne['nom']=$_POST['nom']; 
    $cordonne['prenom']=$_POST['prenom']; 
    $cordonne['datedebut']=$_POST['dateDebut']; 
    $cordonne['solde']=$_POST['solde']; 
    $cordonne['identifient']=$_POST['identifient']; 
    $cordonne['photo']=$_POST['photo']; 
    $cordonne['fid']=$_POST['clientFid']; 
    $cordonne['codebarre']=$_POST['codebarre']; 

    $res = $client->call('InsertUser',array('cordonne'=>$cordonne)); 
     print_r($res); 

Hiçbir şey ekranı İşte

dosya sunucusudur.

cevap

0

sadece anahtar

$res = $client->call('InsertUser',array($cordonne)); 
olmadan diziyi göndermek

$server->wsdl->addComplexType(
'cordonne', 
'complexType', 
'struct', 
'all', 
'', 
array(
     'id'=> array('name' => 'id', 'type' => 'xsd:int'), 
     'prenom'=> array('name' => 'prenom', 'type' => 'xsd:string'), 
     'lastname'=> array('name' => 'lastname', 'type' => 'xsd:string'), 
     'datedebut'=> array('name' => 'datedebut', 'type' => 'xsd:date'), 
     'solde'=> array('name' => 'solde', 'type' => 'xsd:decimal'), 
     'identifient'=> array('name' => 'identifient', 'type' => 'xsd:string'), 
     'photo' => array('name' => 'photo', 'type' => 'xsd:string'), 
     'fid'=> array('name' => 'fid', 'type' => 'xsd:int'), 
     'codebarre' => array('name' => 'codebarre', 'type' => 'xsd:string') 
    )); 

Ve yerine sunucuya anahtarla diziyi geçme complexType dizisinin tanımı doğru dizi anahtarlarını kullanın

İlgili konular