Foros del Web » Programando para Internet » PHP »

Consumir web services php nusoap

Estas en el tema de Consumir web services php nusoap en el foro de PHP en Foros del Web. Buen dia. De antemano gracias por la atencion y/o colaboracion. tengo el siguiente codigo que consume un web service require_once('../nusoap/nusoap.php'); $url = 'http://www.webservicex.net/globalweather.asmx?wsdl'; $soapclient = ...
  #1 (permalink)  
Antiguo 31/05/2010, 21:41
 
Fecha de Ingreso: marzo-2003
Mensajes: 164
Antigüedad: 21 años, 1 mes
Puntos: 0
Consumir web services php nusoap

Buen dia.

De antemano gracias por la atencion y/o colaboracion.

tengo el siguiente codigo que consume un web service

require_once('../nusoap/nusoap.php');
$url = 'http://www.webservicex.net/globalweather.asmx?wsdl';
$soapclient = new soapclient($url, TRUE);
$function = 'GetWeather';
$params = array('CityName' => 'medellin','CountryName' => 'colombia');
$result = $soapclient->call($function , $params);

if (!$error = $soapclient->getError())
echo "Resultado: ".print_r ($result);
else
echo "ERROR:".print_r ($error);

pero no me esta funcionando me sale este error
soap:Server: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'getWeather' expects parameter '@CountryName', which was not supplied. at System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNo nQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at WebServicex.GlobalWeather.GetWeather(String CityName, String CountryName) --- End of inner exception stack trace ---ERROR:1


Probe con soapUI y este funciona perfecto,

Este codigo fue basado en este:


require_once('../nusoap/nusoap.php');
$url = 'http://dev.deepinphp.com/ejemplos/webservices/server.php?wsdl';
$soapclient = new soapclient($url, TRUE);
$function = 'hola';
$params = array('nombre' => 'Pepe');
$result = $soapclient->call($function , $params);

if (!$error = $soapclient->getError())
echo "Resultado: ".$result;
else
echo "ERROR:".$error;


Les agradeceria cualquier colaboracion que me guie al respecto.
  #2 (permalink)  
Antiguo 31/05/2010, 23:43
Avatar de mortiprogramador
Colaborador
 
Fecha de Ingreso: septiembre-2009
Ubicación: mortuoria
Mensajes: 3.805
Antigüedad: 14 años, 7 meses
Puntos: 214
Respuesta: Consumir web services php nusoap

Hola
Bueno, en algunas versiones de nusoap da inconvenientes llamar al client así:

Código PHP:
Ver original
  1. new soapclient

intentalo así

Código PHP:
Ver original
  1. new nusoap_client

saludos
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, si nadie puede detenerte, te conviertes en algo muy diferente."
Visita piggypon.com
  #3 (permalink)  
Antiguo 01/06/2010, 19:17
 
Fecha de Ingreso: marzo-2003
Mensajes: 164
Antigüedad: 21 años, 1 mes
Puntos: 0
Respuesta: Consumir web services php nusoap

MortiProgramador, gracias por la colaboracion.

cambie el codigo pero sale error,

Fatal error: Class 'soap_client' not found in C:\AppServ\www\ws\ejemplows-
ok\ejemplo\Pruebas31052010.php on line 6

no creo que sea eso pues con el otro web service funciona bien, de todos modos mil gracias

Cita:
Iniciado por mortiprogramador Ver Mensaje
Hola
Bueno, en algunas versiones de nusoap da inconvenientes llamar al client así:

Código PHP:
Ver original
  1. new soapclient

intentalo así

Código PHP:
Ver original
  1. new nusoap_client

saludos
  #4 (permalink)  
Antiguo 01/06/2010, 19:35
 
Fecha de Ingreso: marzo-2003
Mensajes: 164
Antigüedad: 21 años, 1 mes
Puntos: 0
Respuesta: Consumir web services php nusoap

Baje la ultima version de nusoap y con esa me funciono:
este es el codigo:

<?php
require_once('../lib/nusoap.php');

$url = 'http://www.webservicex.net/globalweather.asmx?wsdl';
$soapclient = new soapclient($url, TRUE);
$function = 'GetWeather';
$params = array('CityName' => 'medellin','CountryName' => 'colombia');
$result = $soapclient->call($function , $params);

if (!$error = $soapclient->getError())
echo "Resultado: ".print_r ($result);
else
echo "ERROR:".print_r ($error);
?>

y la version nusoap-0.9.5, tu comentario de version me ayudo mucho

saludos y mil gracias,

Etiquetas: consumir, nusoap, services
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.
Tema Cerrado




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