Ver Mensaje Individual
  #3 (permalink)  
Antiguo 16/07/2012, 05:09
uchihah
 
Fecha de Ingreso: enero-2010
Ubicación: Barcelona, España
Mensajes: 57
Antigüedad: 14 años, 4 meses
Puntos: 3
Respuesta: Capturar datos de XML en webservice!

Hola topo_bionico, muchas gracias x responder, basandome en lo que me dices me ha quedado el siguiente codigo que tampoco me funciona pues no me devuelve nada pues cuando la variable llega al WS llega de forma de string y no logro hacer que llegue con el formato XML que es lo que necesito, agradecere muchisimo tu ayuda con esto, aqui esta el codigo:

ws-server.php

Código PHP:
Ver original
  1. <?php
  2. require_once 'lib/nusoap.php';
  3. $ns = "http://localhost/yandy/";
  4. $server = new soap_server();
  5. $server->configureWSDL('WmSocioRegistradoImportacion',$ns);
  6. $server->wsdl->schemaTargetNamespace = $ns;
  7.  
  8. $server->register('ImportarDatos',array('xmlstr' => 'xsd:string'),array('return' => 'xsd:string'),$ns);
  9.  
  10. function ImportarDatos($xmlstr){
  11.    
  12.    $miXml = simplexml_load_string($xmlstr);
  13.    $salida = "";
  14.    foreach ($xml->mensaje as $mensaje)
  15.          $salida .= $mensaje->texto.' ';
  16.  
  17.  
  18.    return new soapval('return', 'xsd:string', $salida);
  19. }
  20.  
  21. if (isset($HTTP_RAW_POST_DATA))
  22. {
  23.     $input = $HTTP_RAW_POST_DATA;
  24. }
  25. else
  26. {
  27.     $input = implode("\r\n", file('php://input'));
  28. }
  29. $server->service($input);
  30. ?>

ws-cliente.php

Código PHP:
Ver original
  1. <?php
  2. require_once 'lib/nusoap.php';
  3. $wsdl = "http://localhost/yandy/ws-server.php?wsdl";
  4. $cliente = new nusoap_client($wsdl, 'wsdl');
  5.  
  6. $xmlstr = <<<XML
  7. <?xml version='1.0'?>
  8. <mensajes>
  9.   <mensaje>
  10.     <asunto>Hola</asunto>
  11.     <texto>Hola, que tal?</texto>
  12.   </mensaje>
  13.   <mensaje>
  14.     <asunto>Re: Hola</asunto>
  15.     <texto>Bien, gracias.</texto>
  16.   </mensaje>
  17. </mensajes>
  18. XML;
  19.  
  20. $params = array('xmlstr' => $xmlstr);
  21. $response = $cliente->call('ImportarDatos', $params);
  22.  
  23. echo $response;
  24. ?>

muchas gracias desde ya
un saludo