Link to home
Start Free TrialLog in
Avatar of altariamx2003
altariamx2003Flag for Mexico

asked on

how to read an external wsdl file in php

I have this wsdl file : http://www.banxico.org.mx/DgieWSWeb/DgieWS?WSDL

I need to create a php program that catch in real time the exchange rate from USD dollar to MXN mexican pesos.

The wsdl file is from "banco de mexico".

From this file the exchange rate is on the element "tiposDeCambioBanxico":
<wsdl:operation name="tiposDeCambioBanxico">
  <wsdlsoap:operation soapAction=""/>
    <wsdl:input name="tiposDeCambioBanxicoRequest">
        <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.dgie.banxico.org.mx" use="encoded"/>
   </wsdl:input>
   <wsdl:output name="tiposDeCambioBanxicoResponse">
       <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://ws.dgie.banxico.org.mx" use="encoded"/>
   </wsdl:output>
</wsdl:operation>

Open in new window


With this code I try to read it
    require_once('lib/nusoap.php');
    
    $oSoapClient = new nusoap_client('http://www.banxico.org.mx:80/DgieWSWeb/DgieWS?WSDL','wsdl');
        
    if ($sError = $oSoapClient->getError()) {
        echo "No se pudo realizar la operación [" . $sError . "]";
        die();
    }

    $respuesta = $oSoapClient->call("tiposDeCambioBanxico");

    if ($oSoapClient->fault) { 
        echo 'No se pudo completar la operación';
        die();
    }else { 
        $sError = $oSoapClient->getError();

        if ($sError) { 
            echo 'Error:' . $sError;
            die();
        }
        echo "Funciono correctamente<br/>";
        echo "<pre>";print_r($respuesta,false); echo "</pre>";
        echo $respuesta["OBS_VALUE"];        
    } 

Open in new window


It seems to work but no matter what I do It always show me the following:
---------------------------------------------------------------------------------------------------------
            TIPOSDECAMBIO
            false
            false
            Tipos de Cambio
            2015-09-10 13:31:36.236
            
                  Banco de México
                  
                  Subgerencia de Desarrollo de Sistemas
                  (01 55)52372678
                  
            
            Update
            2015-09-10 13:31:36.236
------------------------------------------------------------------------------------
What Im doing wrong???

What else do I need to do catch the exchange rate(TIPOSDECAMBIO)

Best regards

Carlos Alvarez
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of altariamx2003

ASKER

it works

this will be really help me a lot

thanks

P.s. Thanks to take time to answer me
Mr. Alvarez:  Thanks for the points and thanks for using E-E.  Best of luck with the project, ~Ray