dongxiane0395 2016-08-26 18:09
浏览 48
已采纳

通过任务计划程序找不到类SoapClient

I have a script that works perfectly if I run the page through the browser, but if I try to set the script to run with Windows Task Scheduler I get the

"Fatal error: Class 'SoapClient' not found" error.

I have Soap extension enabled in the php.ini. This is what I have set in the action for the scheduled task:

Program = D:\wamp\bin\php\php5.4.16\php.exe
Arguments  = -f D:\wamp\www\Web\ScheduledTasks\Import.php
Start In = D:\wamp\www\Web\ScheduledTasks

Here is the code that I am using for the SoapClient:

$Client = new SoapClient("https://www.domain.com/services/secureWebService.svc?wsdl",
        array('location' => 'https://www.domain.com/services/secureWebService.svc/soap',
        'cache_wsdl' => WSDL_CACHE_NONE));

AddWCFUsernameToken($Client, 'Username', 'Password');

function AddWCFUsernameToken($Client, $username, $password) {
            $wssNamespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
            $username = new SoapVar($username, XSD_STRING, null, null, 'Username', $wssNamespace);
            $password = new SoapVar($password, XSD_STRING, null, null, 'Password', $wssNamespace);
            $usernameToken = new SoapVar(array($username, $password), SOAP_ENC_OBJECT, null, null,'UsernameToken', $wssNamespace);
            $usernameToken = new SoapVar(array($usernameToken), SOAP_ENC_OBJECT, null, null, null, $wssNamespace);
            $wssUsernameTokenHeader = new SoapHeader($wssNamespace, 'Security', $usernameToken);
            $Client->__setSoapHeaders($wssUsernameTokenHeader);
        }

Like I said before if I run this page directly from the browser it works perfectly fine, but it only gives me this error when I try to have Windows Task Scheduler run the page.

  • 写回答

1条回答 默认 最新

  • doulipi3742 2016-08-28 23:23
    关注

    Thanks to Andrej, need to make sure that both php.ini files have the soap module turned on, if you have two php.ini files. I have two, one in the Apache folder and one in the PHP folder.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料