Foros del Web » Programando para Internet » PHP »

Obtener datos de un Web Service

Estas en el tema de Obtener datos de un Web Service en el foro de PHP en Foros del Web. Hola buenas tardes, Tengo un sitio donde quiero poner la temperatura y la hora de una ciudad de México, ya encontré el web service de ...
  #1 (permalink)  
Antiguo 12/12/2014, 16:19
 
Fecha de Ingreso: febrero-2012
Mensajes: 11
Antigüedad: 12 años, 2 meses
Puntos: 0
Obtener datos de un Web Service

Hola buenas tardes,
Tengo un sitio donde quiero poner la temperatura y la hora de una ciudad de México, ya encontré el web service de donde puedo traer esa información.

[URL="http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Ixtapa-Zihuatanejo&CountryName=Mexico"]http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Ixtapa-Zihuatanejo&CountryName=Mexico[/URL]

Tengo ya este cliente:
<?php

try {
$client = new SoapClient("http://www.webservicex.net/globalweather.asmx?WSDL",
array('cache_wsdl' => WSDL_CACHE_NONE,'trace' => TRUE));
$param = array(
'CityName' => 'Ixtapa-Zihuatanejo',
'CountryName' => 'Mexico'
);

$ready = $client->GetWeather($param)->buscardsResult;
//var_dump($ready); //Verificar si hay resultado

$xml = simplexml_load_string($ready->any);

//Leer una fila de un DataSet.Name = "NewDataSet" que contiene
//un DataSet.Tables[0].Name = "Table"
$row1 = $xml->NewDataSet->Table;

$valueColRow = $xml->NewDataSet->Table->direccion;

var_dump($row1);
print_r($valueColRow);

} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
}
?>

Solo quiero recuperar el contenido de los tags de <Time> y el de <Temperature> alguien puede darme un poco de idea de como hacerlo?


Gracias por su ayuda.
DSM

Última edición por trosh8; 12/12/2014 a las 16:34

Etiquetas: cliente, soap, webservice
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 23:32.