Ver Mensaje Individual
  #4 (permalink)  
Antiguo 09/10/2007, 09:44
Avatar de helder
helder
 
Fecha de Ingreso: agosto-2007
Ubicación: Colombia
Mensajes: 50
Antigüedad: 16 años, 9 meses
Puntos: 1
Re: Consumir WebService con NuSOAP?

Pues segun lo que observo el servicio web que has implementado al parecer estan bien , pero de fondo puedes tener problemas en la manera que retornas los valores en las funciones del servicio. no se si me explico asi que te voy a postear un ejemplo haber si te ayuda en tu problema.
esta implementado con nusoap + PHP tanto el cliente como el servicio web pero en teoria se debe hacer igual en cualquien lenguaje (asp.net).

---servicio Web (webser.php) -----

<?php
require_once("nusoap/lib/nusoap.php");
$namespace="http://localhost/prueba/webservices/nusoap";
$server = new soap_server();
$server->configureWSDL('Servicio Web',$namespace);
$server->wsdl->schemaTargetNamespace=$namespace;
$server->register('weserprueba',array( 'x' => 'xsd:int','y'=>'xsd:int'),array('suma' => 'xsd:int','resta'=>'xsd:int','multiplicacion'=>'xsd:int','division'=>'xsd:int'),$namespace);
function weserprueba($x,$y){
$suma=$x+$y;
$resta=$x-$y;
$multiplicacion=$x*$y;
$division=$x/$y;
return array('suma'=>$suma,'resta'=>$resta,'multiplicacion'=>$multiplicacion,'division'=>$division);
}
$server->service($HTTP_RAW_POST_DATA);
?>

------------------------------------------------
----WSDL - XML-----------------------------------

<definitions targetNamespace="http://localhost/prueba/webservices/nusoap">
-
<types>
-
<xsd:schema targetNamespace="http://localhost/prueba/webservices/nusoap">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema>
</types>
-
<message name="weserpruebaRequest">
<part name="x" type="xsd:int"/>
<part name="y" type="xsd:int"/>
</message>
-
<message name="weserpruebaResponse">
<part name="suma" type="xsd:int"/>
<part name="resta" type="xsd:int"/>
<part name="multiplicacion" type="xsd:int"/>
<part name="division" type="xsd:int"/>
</message>
-
<portType name="Servicio WebPortType">
-
<operation name="weserprueba">
<input message="tns:weserpruebaRequest"/>
<output message="tns:weserpruebaResponse"/>
</operation>
</portType>
-
<binding name="Servicio WebBinding" type="tns:Servicio WebPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
-
<operation name="weserprueba">
<soap:operation soapAction="http://localhost/prueba/webservices/webser.php/weserprueba" style="rpc"/>
-
<input>
<soap:body use="encoded" namespace="http://localhost/prueba/webservices/nusoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
-
<output>
<soap:body use="encoded" namespace="http://localhost/prueba/webservices/nusoap" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
-
<service name="Servicio Web">
-
<port name="Servicio WebPort" binding="tns:Servicio WebBinding">
<soap:address location="http://localhost/prueba/webservices/webser.php"/>
</port>
</service>
</definitions>

-------------------------------------------
---cliente, consumido del servicio------

<?php
require_once('nusoap/lib/nusoap.php');
$oSoapClient = new soapclient('http://localhost/prueba/webservices/webser.php','wsdl');
$aParametros = array("x"=> 5,"y" => 4 );
$respuesta = $oSoapClient->call("weserprueba",$aParametros);
print_r($respuesta);
?>
----------------------------------------

La salida en el navegador es:

Array ( [suma] => 9 [resta] => 1 [multiplicacion] => 20 [division] => 1 )