Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/07/2013, 03:36
arhalien
 
Fecha de Ingreso: julio-2013
Mensajes: 4
Antigüedad: 10 años, 10 meses
Puntos: 0
Problema con webservice en PHP & wsdl

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
  1. <?php
  2. // Pull in the NuSOAP code
  3. require_once('lib/nusoap.php');
  4. // Create the server instance
  5. $server = new soap_server();
  6. // Initialize WSDL support
  7. $server->configureWSDL('entregaswsdl', 'urn:entregaswsdl');
  8. // Register the method to expose
  9. $server->register('actualizarEstadoCooperacion',                        // method name
  10.     array('estadoCoop' => 'xsd:string','idEntrega' => 'xsd:integer'),   // input parameters
  11.     array('return' => 'xsd:string'),                                    // output parameters
  12.     'urn:entregaswsdl',                                                 // namespace
  13.     'urn:entregaswsdl#actualizarEstadoCooperacion'                      // soapaction
  14.     //'rpc',                                                            // style
  15.     //'encoded',                                                        // use
  16.     //'Says hello to the caller'                                        // documentation
  17. );
  18. $server->register('actualizarEstadoAsistencia',                         // method name
  19.     array('estadoAsist' => 'xsd:string','idEntrega' => 'xsd:integer'),  // input parameters
  20.     array('return' => 'xsd:string'),                                    // output parameters
  21.     'urn:entregaswsdl',                                                 // namespace
  22.     'urn:entregaswsdl#actualizarEstadoAsistencia'                       // soapaction
  23. );
  24. $server->register('actualizarFechaCooperacion',                         // method name
  25.     array('fechaCoop' => 'xsd:string','idEntrega' => 'xsd:integer'),    // input parameters
  26.     array('return' => 'xsd:string'),                                    // output parameters
  27.     'urn:entregaswsdl',                                                 // namespace
  28.     'urn:entregaswsdl#actualizarFechaCooperacion'                       // soapaction
  29. );
  30. $server->register('actualizarFechaAsistencia',                          // method name
  31.     array('fechaAsist' => 'xsd:string','idEntrega' => 'xsd:integer'),   // input parameters
  32.     array('return' => 'xsd:string'),                                    // output parameters
  33.     'urn:entregaswsdl',                                                 // namespace
  34.     'urn:entregaswsdl#actualizarFechaAsistencia'                        // soapaction
  35. );
  36. // Define the method as a PHP function
  37. class actualizar_entrega
  38. {
  39.    
  40.     public function actualizarEstadoCooperacion($estadoCoop,$idEntrega)
  41.     {
  42.         include 'includes/dbconfig.php';
  43.         $q = "UPDATE entregas SET estado_coop ='".$estadoCoop."' WHERE identrega=".$idEntrega."";
  44.         $rs = pg_query($dbconn_config, $q) or die("Error in query: $q. " . pg_last_error($dbconn_config));
  45.         return "estado coop actualizado";
  46.     }
  47.    
  48.     public function actualizarEstadoAsistencia($estadoAsist,$idEntrega)
  49.     {
  50.         include 'includes/dbconfig.php';
  51.         $q = "UPDATE entregas SET estado_asist ='".$estadoAsist."' WHERE identrega=".$idEntrega."";
  52.         $rs = pg_query($dbconn_config, $q) or die("Error in query: $q. " . pg_last_error($dbconn_config));
  53.         return "estado asist actualizado";
  54.     }
  55.    
  56.     public function actualizarFechaCooperacion($fechaCoop,$idEntrega)
  57.     {
  58.         include 'includes/dbconfig.php';
  59.         $q = "UPDATE entregas SET fecha_coop ='".$fechaCoop."' WHERE identrega=".$idEntrega."";
  60.         $rs = pg_query($dbconn_config, $q) or die("Error in query: $q. " . pg_last_error($dbconn_config));
  61.         return "fecha coop actualizada";
  62.     }
  63.    
  64.     public function actualizarFechaAsistencia($fechaAsist,$idEntrega)
  65.     {
  66.         include 'includes/dbconfig.php';
  67.         $q = "UPDATE entregas SET fecha_asist ='".$fechaAsist."' WHERE identrega=".$idEntrega."";
  68.         $rs = pg_query($dbconn_config, $q) or die("Error in query: $q. " . pg_last_error($dbconn_config));
  69.         return "fecha asist actualizado";
  70.     }
  71. }
  72. // Use the request to (try to) invoke the service
  73. $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  74. $server->service($HTTP_RAW_POST_DATA);
  75. ?>
si accedo a http://127.0.0.1/eiel/trunk/webservi...regas.php?wsdl obtengo:

wsdl


Código XML:
Ver original
  1. <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">
  2. <types>
  3. <xsd:schema targetNamespace="urn:entregaswsdl">
  4. <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
  5. <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
  6. </xsd:schema>
  7. </types>
  8. <message name="actualizarEstadoCooperacionRequest">
  9. <part name="estadoCoop" type="xsd:string"/>
  10. <part name="idEntrega" type="xsd:integer"/>
  11. </message>
  12. <message name="actualizarEstadoCooperacionResponse">
  13. <part name="return" type="xsd:string"/>
  14. </message>
  15. <message name="actualizarEstadoAsistenciaRequest">
  16. <part name="estadoAsist" type="xsd:string"/>
  17. <part name="idEntrega" type="xsd:integer"/>
  18. </message>
  19. <message name="actualizarEstadoAsistenciaResponse">
  20. <part name="return" type="xsd:string"/>
  21. </message>
  22. <message name="actualizarFechaCooperacionRequest">
  23. <part name="fechaCoop" type="xsd:string"/>
  24. <part name="idEntrega" type="xsd:integer"/>
  25. </message>
  26. <message name="actualizarFechaCooperacionResponse">
  27. <part name="return" type="xsd:string"/>
  28. </message>
  29. <message name="actualizarFechaAsistenciaRequest">
  30. <part name="fechaAsist" type="xsd:string"/>
  31. <part name="idEntrega" type="xsd:integer"/>
  32. </message>
  33. <message name="actualizarFechaAsistenciaResponse">
  34. <part name="return" type="xsd:string"/>
  35. </message>
  36. <portType name="entregaswsdlPortType">
  37. <operation name="actualizarEstadoCooperacion">
  38. <input message="tns:actualizarEstadoCooperacionRequest"/>
  39. <output message="tns:actualizarEstadoCooperacionResponse"/>
  40. </operation>
  41. <operation name="actualizarEstadoAsistencia">
  42. <input message="tns:actualizarEstadoAsistenciaRequest"/>
  43. <output message="tns:actualizarEstadoAsistenciaResponse"/>
  44. </operation>
  45. <operation name="actualizarFechaCooperacion">
  46. <input message="tns:actualizarFechaCooperacionRequest"/>
  47. <output message="tns:actualizarFechaCooperacionResponse"/>
  48. </operation>
  49. <operation name="actualizarFechaAsistencia">
  50. <input message="tns:actualizarFechaAsistenciaRequest"/>
  51. <output message="tns:actualizarFechaAsistenciaResponse"/>
  52. </operation>
  53. </portType>
  54. <binding name="entregaswsdlBinding" type="tns:entregaswsdlPortType">
  55. <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  56. <operation name="actualizarEstadoCooperacion">
  57. <soap:operation soapAction="urn:entregaswsdl#actualizarEstadoCooperacion" style="rpc"/>
  58. <input>
  59. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  60. </input>
  61. <output>
  62. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  63. </output>
  64. </operation>
  65. <operation name="actualizarEstadoAsistencia">
  66. <soap:operation soapAction="urn:entregaswsdl#actualizarEstadoAsistencia" style="rpc"/>
  67. <input>
  68. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  69. </input>
  70. <output>
  71. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  72. </output>
  73. </operation>
  74. <operation name="actualizarFechaCooperacion">
  75. <soap:operation soapAction="urn:entregaswsdl#actualizarFechaCooperacion" style="rpc"/>
  76. <input>
  77. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  78. </input>
  79. <output>
  80. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  81. </output>
  82. </operation>
  83. <operation name="actualizarFechaAsistencia">
  84. <soap:operation soapAction="urn:entregaswsdl#actualizarFechaAsistencia" style="rpc"/>
  85. <input>
  86. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  87. </input>
  88. <output>
  89. <soap:body use="encoded" namespace="urn:entregaswsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  90. </output>
  91. </operation>
  92. </binding>
  93. <service name="entregaswsdl">
  94. <port name="entregaswsdlPort" binding="tns:entregaswsdlBinding">
  95. <soap:address location="http://127.0.0.1/eiel/trunk/webservice_entregas.php"/>
  96. </port>
  97. </service>
  98. </definitions>


Por último he creado el cliente para comprobar que puedo acceder:

Cliente


Código PHP:
Ver original
  1. $identrega = 21;
  2. $estadocoop = "A";
  3. $url = 'http://127.0.0.1/eiel/trunk/webservice_entregas.php?wsdl';
  4. $objClient = new SoapClient($url, array('trace' => 1, 'connection_timeout' => 10,'exceptions' => 1,'encoding' => 'ISO-8859-1'));
  5. $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>';
  6. $xmlRespuesta = $objClient->actualizarEstadoCooperacion($xmlStr);
  7. 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

Última edición por Triby; 05/07/2013 a las 03:49 Razón: Poner código en Highlight