Re: Changing version from PHP4 to PHP5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gracias Iván,

Ya lo he resuelto. Tan sencillo como:

function checkUser($user, $pass)
{
$client = new soapclient("http://80.32.91.149:25000/servicioXYZ.asmx?WSDL";);
     $params = array(
                                 'RutaTabla'  => "d:\\ourpw\\",
                                 'ElUsuario'  => $user,
                                 'ElPassword' => $pass,
                                 'QuienEs'    => 'CLIENTE'
                               );

     $ok = $client->AutentificaPW($params);

     $result = $ok->AutentificaPWResult;

$tagsToSearch = Array("nombre", "situacion", "email", "codigo", "pagina");

     $tagObj = publis_TagsToArray($result, $tagsToSearch);

     return $tagObj;
}

Gracias a todos

Thank you


Ivan Rodriguez escribió:
Hola Luis, te contesto en castellano por que creo que eres hispanohablante :-)

El problema que tienes es que tienes que migrar el cliente utilizando la API que tiene PHP para ellos, para eso cuentas con la clase SoapClient, y utilizar los métodos de esa clase. Actualmente esta haciendo uso de algo que no existe, como es el método getProxy(), el objeto entiende que ese método no esta definido en el fichero WSDL.

Te recomiendo que visites y leas http://php.net/soap ahí encontrarás ejemplos de como crear un cliente SOAP utilzando PHP5.

Recuerda que puedes ver los métodos disponibles y los tipos de datos utilizando la función __getFunctions() y __getTypes() respectivamente.

Un saludo

On Sat, Oct 31, 2009 at 3:32 PM, I.N.T. - Luis <luis@grupo-int.com <mailto:luis@grupo-int.com>> wrote:

    Hi everybody,

    We have some code written for PHP4 using the SOAP libraries for
    connect as a CLIENT to a web service. The web service SERVER is
    not ours, we don´t know how it is programed. The code is:

    require_once('lib/nusoap.php'); // where we are publishing the
    SOAP libraries

    function checkUser($user, $pass)
    {
          $client = new
    soapclient("http://80.32.91.149:25000/servicioXYZ.asmx?WSDL";, "wsdl");
          $params = array(
                                      'RutaTabla'  => "d:\\ourpw\\",
                                      'ElUsuario'  => $user,
                                      'ElPassword' => $pass,
                                      'QuienEs'    => 'CLIENTE'
                                    );

          $theProxy = $client->getProxy();
          $ok = $theProxy->AutentificaPW($params);

          $result = $ok["AutentificaPWResult"];

          $tagsToSearch = Array("nombre", "situacion", "email",
    "codigo", "pagina");

          $tagObj = publis_TagsToArray($result, $tagsToSearch);  //
    this is a internal function we use

          return $tagObj;
    }

    IT WORKED FINE!!!

    Now we have actualized our systems to PHP5 obligatory.

    The error is:

    *Warning*: SoapClient::SoapClient() expects parameter 2 to be
    array, string given in *xxx.php* on line *13*

    *Fatal error*: Uncaught SoapFault exception: [Client]
    SoapClient::SoapClient() [<a
    href='soapclient.soapclient'>soapclient.soapclient</a>]: Invalid
    parameters in xxx.php:13 Stack trace: #0 xxx.php(13):
    SoapClient->SoapClient('http://80.32.91...', 'wsdl') #1
    xxx.php(163): checkUser('XXX', 'YYY') #2 {main} thrown in
    *xxx.php* on line *13

    *OK, looking for "new" SOAP functions, I change my code as:

    //require_once('lib/nusoap.php'); // using internal SOAP PHP libraries

    function checkUser($user, $pass)
    {
          $client = new
    soapclient("http://80.32.91.149:25000/servicioXYZ.asmx?WSDL";);
          $params = array(
                                      'RutaTabla'  => "d:\\ourpw\\",
                                      'ElUsuario'  => $user,
                                      'ElPassword' => $pass,
                                      'QuienEs'    => 'CLIENTE'
                                    );

          $theProxy = $client->getProxy();
          $ok = $theProxy->AutentificaPW($params);

          $result = $ok["AutentificaPWResult"];

          $tagsToSearch = Array("nombre", "situacion", "email",
    "codigo", "pagina");

          $tagObj = publis_TagsToArray($result, $tagsToSearch);  //
    this is a internal function we use

          return $tagObj;
    }

    The error is:

    *Fatal error*: Uncaught SoapFault exception: [Client] Function
    ("getProxy") is not a valid method for this service in xxx.php:22
    Stack trace: #0 [internal function]:
    SoapClient->__call('getProxy', Array) #1 xxx.php(22):
    SoapClient->getProxy() #2 xxx.php(163): checkUser('XXX', 'YYY') #3
    {main} thrown in *xxx.php* on line *22

    *As you can see I need the variable $theProxy to authenticate the
    password against the proxy. Looking for help in the web, I haven't
    find valid ideas to correct this.

    How could I do it? The code, in my opinion is very simple, but I'm
    not able to correct or adapt it to PHP5 with ne new SOAP libraries
    (functions).

    What's wrong? Any idea?

    Thank you very much




[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux