Run the webservice via CMD returns NULL

Asked

Viewed 260 times

1

I have the code below that I need to run every hour. This script running by the browser returns the data correctly. Intended to run it via scheduled tasks, by CMD through execution lines:

c:/caminhocorreto/php -c c:/caminho/para/o/php.ini [ -f ] c:/caminho/para/o/script.php or php -f c:/caminho/para/o/script.php

The problem that by the first command, returns that you did not find the libraries (defined in php.ini): Warning: PHP Startup: Unable to load dynamic library '${path}\binaries\php\ext\php_xsl.dll' - Não foi possível encontrar o módulo especificado. in Unknown on line 0

In the second command, he falls into the catch and returns me NULL. Trying to run a simple page.

ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', 900);
ini_set('default_socket_timeout', 15);


header('Content-Type: text/html; charset=utf-8');
include('../includes/class.usuario.php');
include('../includes/conexao.php'   );

$params = array(
    'usuario' => $usuario,
    'senha' => $senha,
    'quantidade' => 10
);

$wsdl = 'http://site_de_consulta_webservice?WSDL';

$options = array(
        'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
        'style'=>SOAP_RPC,
        'use'=>SOAP_ENCODED,
        'soap_version'=>SOAP_1_1,
        'cache_wsdl'=>WSDL_CACHE_NONE,
        'connection_timeout'=>15,
        'trace'=>true,
        'encoding'=>'UTF-8',
        'exceptions'=>true,
    );
try {
    $soap = new SoapClient($wsdl, $options);        
    $data = $soap->obterPacotePosicoes($params);        

}
catch (SoapFault $fault){       
    echo "\n\n".$fault->getMessage();
}

$i = 0;

foreach($data->return as $posicao)
{
    $cod_macro = $posicao->codigoMacro;

    //INSERT DOS DADOS NO BANCO DE DADOS A CADA EXECUÇÃO DO SISTEMA!
}

Can anyone tell if there is a problem in browsing webservice via prompt? Or if there is something wrong? And because the first command happens the failure to find the libs?

EDIT

C:\>php -v
PHP 5.4.24 (cli) (built: Jan  8 2014 20:26:31)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

C:\>php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
odbc
openssl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
yaz
zip
zlib

[Zend Modules]
Xdebug

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

  • 1

    In CMD, run this: php -v. Perform as well php -m. Put in the question the result of both. Running through the browser, do another test. Save a file as "info.php". In this file, just put this <?php phpinfo();. Post a printscreen of what resulted. (This is not the solution. They are diagnostic tests.)

  • 1

    @Danielomine this?

  • 1

    ok, run this via browser: <?php print_r(get_loaded_extensions());. Post the result. Use and execute this same route CMD.

  • @Danielomine, made... using C:\>php -r print_r(get_loaded_extensions()); direct via CMD the result is the same.

  • 1

    One question I have is, in the first command the full php compiler path is declared c:/caminhocorreto/php. The second one is already accessed by an alias. Does this alias lead to the same absolute path compiler as the first command? php.ini in both is the same? In the result of phpinfo() we can see the path of php.ini. Is this the same path used in the first command? The initial suspicion is that it has more than one php installation or more than one startup file (php.ini)

  • @Danielomine checking here, actually on the first path I was using another path from php.ini. Now both options return NULL and no mistake. An error I discovered, but I have not solved the main rsrs

  • @Danielomine the mistake is that by CMD he does not add the includes. It is possible to treat this to perform correctly?

  • 1

    Do you speak of user and connection includes? If so, avoid relative path. Set absolute path. include(__DIR__.'/../includes/class.usuario.php');

  • 1

    @Danielomine that same, I just found here too, tested and worked perfectly.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.