Foros del Web » Programando para Internet » PHP » Zend »

Agregar Array a Zend SOAP

Estas en el tema de Agregar Array a Zend SOAP en el foro de Zend en Foros del Web. Amigos mios, Estoy intentanto crear un Web Service con Zend-SOAP pero estoy parado ya que no se como enviar arrays. La idea es tener un ...
  #1 (permalink)  
Antiguo 10/07/2013, 14:44
Avatar de xalupeao  
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 16 años
Puntos: 12
Agregar Array a Zend SOAP

Amigos mios,

Estoy intentanto crear un Web Service con Zend-SOAP pero estoy parado ya que no se como enviar arrays.

La idea es tener un metodo getAllUsers() y que este me entrege un array con todos los usuarios.


hasta ahora tengo esto

Service.php
Código PHP:
<?php
/**
* Service Class
*/
class Service
{
    
/**
     * Obtener la lista de Clientes
     * @return array
     */
    
public function getCustomers()
    {
        
$customers = array(
                        
=> array('fist_name' => 'XXXX'),
                        
=> array('fist_name' => 'XXXX'),
                    );
        return 
$customers;
    }
}
Server.php
Código PHP:
<?php
require_once 'vendor/autoload.php';
use 
ZendSoapAutoDiscover;


$wsdl = new AutoDiscover();
$wsdl->setClass('Service')
    ->
setUri('http://dev/soap/zend/soap_server.php?wsdl')
    ->
setServiceName('SakilaService')
    ->
handle();

Client.php
Código PHP:
<?php
require_once 'vendor/autoload.php';
use 
ZendSoapClient;


$client = new Client('http://dev/soap/zend/soap_server.php?wsdl');

print_r($client->getCustomers());

y obtengo lo siguiente:


Cita:

Fatal error: Uncaught SoapFault exception: [VersionMismatch] Wrong Version in C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client.php:1118 Stack trace: #0 C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client.php(1118): SoapClient->__soapCall('getCustomers', Array, NULL, NULL, Array) #1 C:\xampp\htdocs\Developer\soap\zend\soap_client.ph p(8): Zend\Soap\Client->__call('getCustomers', Array) #2 C:\xampp\htdocs\Developer\soap\zend\soap_client.ph p(8): Zend\Soap\Client->getCustomers() #3 {main} thrown in C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client.php on line 1118

Amigos espero que me puedan ayudar, he intentado ir a la documentacion pero la verdad no logro entendarla del todo.


Saludos!
__________________
Hosting en Chile en Silverhost - La solución en Hosting en Chile.
  #2 (permalink)  
Antiguo 10/07/2013, 15:46
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Agregar Array a Zend SOAP

Estas construyendo mal el servidor, prueba algo así:
Código PHP:
Ver original
  1. require_once 'vendor/autoload.php';
  2.  
  3. if (isset($_GET['wsdl'])) {
  4.     $autodiscover = new Zend\Soap\AutoDiscover();
  5.     ini_set("soap.wsdl_cache_enabled", 0);
  6.     $autodiscover->setClass('UserService');
  7.     $autodiscover->handle();
  8. } else {
  9.     $server = new Zend\Soap\Server("http://dev/soap/zend/soap_server.php?wsdl");
  10.     $server->setClass('UserService');
  11.     $server->handle();
  12. }

Saludos.
  #3 (permalink)  
Antiguo 11/07/2013, 11:43
Avatar de xalupeao  
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 16 años
Puntos: 12
Respuesta: Agregar Array a Zend SOAP

Cambie la estructura por la que me indicas y obtengo lo siguiente al ejecutar el cliente.

Cita:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://dev/soap/zend/soap_server.php?wsdl' : Extra content at the end of the document in C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client\Common.php:35 Stack trace: #0 C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client\Common.php(35): SoapClient->SoapClient('http://dev/soap...', Array) #1 C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client.php(1024): Zend\Soap\Client\Common->__construct(Array, 'http://dev/soap...', Array) #2 C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client.php(1196): Zend\Soap\Client->_initSoapClientObject() #3 C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client.php(1107): Zend\Soap\Client->getSoapClient() #4 C:\xampp\htdocs\Developer\soap\zend\soap_client.ph p(8): Zend\Soap\Client->__call('getCustomers', Array) #5 C:\xampp\htdocs\Developer\soap\z in C:\xampp\htdocs\Developer\soap\zend\vendor\zendfra mework\zend-soap\Zend\Soap\Client\Common.php on line 35
Desde ya gracias :)
__________________
Hosting en Chile en Silverhost - La solución en Hosting en Chile.
  #4 (permalink)  
Antiguo 11/07/2013, 12:04
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Agregar Array a Zend SOAP

¿y ya abriste la URL para ver que efectivamente esta devolviendo correctamente el WSDL?
  #5 (permalink)  
Antiguo 11/07/2013, 18:09
Avatar de xalupeao  
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 16 años
Puntos: 12
Respuesta: Agregar Array a Zend SOAP

Flataba el setUri() del Autodiscover.

Muchas gracias GatorV te pasaste!
__________________
Hosting en Chile en Silverhost - La solución en Hosting en Chile.

Etiquetas: html, php, soap, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:04.