Ver Mensaje Individual
  #9 (permalink)  
Antiguo 10/05/2013, 17:10
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: conectar web service con mysql en zend

Es lo mismo para 2+: http://framework.zend.com/manual/2.1...ap.server.html

Simplemente creas tu clase, ej:
Código PHP:
Ver original
  1. class MyDemoClass {
  2.         private $studentTable;
  3.         public function getStudentTable()
  4.         {
  5.                  return $this->studentTable;
  6.         }
  7.  
  8.         public function setStudentTable(AbstractTableGateway $studentTable)
  9.         {
  10.                  $this->studentTable = $studentTable;
  11.                  return $this;
  12.         }
  13.  
  14.         public function getStudents()
  15.         {
  16.                 $studentTable = $this->getStudentTable();
  17.                 $students = $studentTable->getAllStudents();
  18.  
  19.                 return $students;
  20.         }
  21. }
  22.  
  23. // Luego en tu action controller extraes tu clase del ServiceLocator (o lo inyectas al controller) creas un ZendSoapServer y listo
  24. public function handleserviceAction() {
  25.         $studentTable = $this->getServiceLocator()->get('MyDemoClass');
  26.         $server = new Zend\Soap\Server(null, $options);;
  27.         $server->setObject($studentTable);
  28.         $server->handle();
  29. }

En tu TableGateway es justamente donde usas MySQL o realmente lo que quieras, ya que usas Zend\Db para comunicarte y extraer la información, puedes ver este ejemplo: http://blog.evan.pro/zf2-tablegateway-hydration

Realmente no es muy complicado y con eso ya puedes usar clientes que se conecten en modo SOAP a tu servidor.

Claro todo esto es en teoría que sí necesites un WebService SOAP, y no de otro tipo (RESTful por ejemplo).

Saludos.