通过任务计划程序找不到类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.

查看全部
dongxiane0395
dongxiane0395
2016/08/26 18:09
  • php
  • soap
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复