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.

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

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题