Hola a todos!
Soy bastante novato en webservices y tengo que publicar un wsdl y comprobar que el cliente puede acceder a sus métodos. Esto es lo que tengo hecho
Servidor
Código PHP:
Ver original<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('entregaswsdl', 'urn:entregaswsdl');
// Register the method to expose
$server->register('actualizarEstadoCooperacion', // method name
array('estadoCoop' => 'xsd:string','idEntrega' => 'xsd:integer'), // input parameters array('return' => 'xsd:string'), // output parameters 'urn:entregaswsdl', // namespace
'urn:entregaswsdl#actualizarEstadoCooperacion' // soapaction
//'rpc', // style
//'encoded', // use
//'Says hello to the caller' // documentation
);
$server->register('actualizarEstadoAsistencia', // method name
array('estadoAsist' => 'xsd:string','idEntrega' => 'xsd:integer'), // input parameters array('return' => 'xsd:string'), // output parameters 'urn:entregaswsdl', // namespace
'urn:entregaswsdl#actualizarEstadoAsistencia' // soapaction
);
$server->register('actualizarFechaCooperacion', // method name
array('fechaCoop' => 'xsd:string','idEntrega' => 'xsd:integer'), // input parameters array('return' => 'xsd:string'), // output parameters 'urn:entregaswsdl', // namespace
'urn:entregaswsdl#actualizarFechaCooperacion' // soapaction
);
$server->register('actualizarFechaAsistencia', // method name
array('fechaAsist' => 'xsd:string','idEntrega' => 'xsd:integer'), // input parameters array('return' => 'xsd:string'), // output parameters 'urn:entregaswsdl', // namespace
'urn:entregaswsdl#actualizarFechaAsistencia' // soapaction
);
// Define the method as a PHP function
class actualizar_entrega
{
public function actualizarEstadoCooperacion($estadoCoop,$idEntrega)
{
include 'includes/dbconfig.php';
$q = "UPDATE entregas SET estado_coop ='".$estadoCoop."' WHERE identrega=".$idEntrega."";
return "estado coop actualizado";
}
public function actualizarEstadoAsistencia($estadoAsist,$idEntrega)
{
include 'includes/dbconfig.php';
$q = "UPDATE entregas SET estado_asist ='".$estadoAsist."' WHERE identrega=".$idEntrega."";
return "estado asist actualizado";
}
public function actualizarFechaCooperacion($fechaCoop,$idEntrega)
{
include 'includes/dbconfig.php';
$q = "UPDATE entregas SET fecha_coop ='".$fechaCoop."' WHERE identrega=".$idEntrega."";
return "fecha coop actualizada";
}
public function actualizarFechaAsistencia($fechaAsist,$idEntrega)
{
include 'includes/dbconfig.php';
$q = "UPDATE entregas SET fecha_asist ='".$fechaAsist."' WHERE identrega=".$idEntrega."";
return "fecha asist actualizado";
}
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA);
?>
si accedo a http://127.0.0.1/eiel/trunk/webservi...regas.php?wsdl obtengo:
wsdl
Código XML:
Ver original<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:entregaswsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:entregaswsdl">
<types>
<xsd:schema targetNamespace="urn:entregaswsdl">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema>
</types>
<message name="actualizarEstadoCooperacionRequest">
<part name="estadoCoop" type="xsd:string"/>
<part name="idEntrega" type="xsd:integer"/>
</message>
<message name="actualizarEstadoCooperacionResponse">
<part name="return" type="xsd:string"/>
</message>
<message name="actualizarEstadoAsistenciaRequest">
<part name="estadoAsist" type="xsd:string"/>
<part name="idEntrega" type="xsd:integer"/>
</message>
<message name="actualizarEstadoAsistenciaResponse">
<part name="return" type="xsd:string"/>
</message>
<message name="actualizarFechaCooperacionRequest">
<part name="fechaCoop" type="xsd:string"/>
<part name="idEntrega" type="xsd:integer"/>
</message>
<message name="actualizarFechaCooperacionResponse">
<part name="return" type="xsd:string"/>
</message>
<message name="actualizarFechaAsistenciaRequest">
<part name="fechaAsist" type="xsd:string"/>
<part name="idEntrega" type="xsd:integer"/>
</message>
<message name="actualizarFechaAsistenciaResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="entregaswsdlPortType">
<operation name="actualizarEstadoCooperacion">
<input message="tns:actualizarEstadoCooperacionRequest"/>
<output message="tns:actualizarEstadoCooperacionResponse"/>
</operation>
<operation name="actualizarEstadoAsistencia">
<input message="tns:actualizarEstadoAsistenciaRequest"/>
<output message="tns:actualizarEstadoAsistenciaResponse"/>
</operation>
<operation name="actualizarFechaCooperacion">
<input message="tns:actualizarFechaCooperacionRequest"/>
<output message="tns:actualizarFechaCooperacionResponse"/>
</operation>
<operation name="actualizarFechaAsistencia">
<input message="tns:actualizarFechaAsistenciaRequest"/>
<output message="tns:actualizarFechaAsistenciaResponse"/>
</operation>
</portType>
<binding name="entregaswsdlBinding" type="tns:entregaswsdlPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="actualizarEstadoCooperacion">
<soap:operation soapAction="urn:entregaswsdl#actualizarEstadoCooperacion" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="actualizarEstadoAsistencia">
<soap:operation soapAction="urn:entregaswsdl#actualizarEstadoAsistencia" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="actualizarFechaCooperacion">
<soap:operation soapAction="urn:entregaswsdl#actualizarFechaCooperacion" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="actualizarFechaAsistencia">
<soap:operation soapAction="urn:entregaswsdl#actualizarFechaAsistencia" style="rpc"/>
<input>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="entregaswsdl">
<port name="entregaswsdlPort" binding="tns:entregaswsdlBinding">
<soap:address location="http://127.0.0.1/eiel/trunk/webservice_entregas.php"/>
</port>
</service>
</definitions>
Por último he creado el cliente para comprobar que puedo acceder:
Cliente
Código PHP:
Ver original$identrega = 21;
$estadocoop = "A";
$url = 'http://127.0.0.1/eiel/trunk/webservice_entregas.php?wsdl';
$objClient = new SoapClient
($url, array('trace' => 1, 'connection_timeout' => 10,'exceptions' => 1,'encoding' => 'ISO-8859-1')); $xmlStr = '<urn:actualizarEstadoCooperacion xmlns:urn="urn:entregaswsdl"><urn:estadoCoop xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$estadocoop.'</urn:estadoCoop><urn:idEntrega xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$identrega.'</urn:idEntrega></urn:actualizarEstadoCooperacion>';
$xmlRespuesta = $objClient->actualizarEstadoCooperacion($xmlStr);
echo $xmlRespuesta;
Pero cuando accedo al cliente me da el siguiente error:
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] method 'actualizarEstadoCooperacion'('actualizarEstadoCoo peracion') not defined in service('' '') in C:\ms4w\apps\eiel\trunk\enviarEntrega.php:8 Stack trace: #0 [internal function]: SoapClient->__call('actualizarEstad...', Array) #1 C:\ms4w\apps\eiel\trunk\enviarEntrega.php(8): SoapClient->actualizarEstadoCooperacion('<urn:actualizar... ') #2 {main} thrown in C:\ms4w\apps\eiel\trunk\enviarEntrega.php on line 8
Alguna idea de por que me da este error?
Gracias de antemano