SoapClient和Laravel

时间:2018-10-01 13:37:25

标签: php soap-client

我正在尝试使用SoapClient向WSDL文件发送请求,但收到此错误

Class 'App\Http\Controllers\SoapClient' not found

我尝试添加\SoapClient->callSoap()use SoapClient;仍然出错,并且我的肥皂扩展名已启用

这是我的控制器中的代码

 $client  = new SoapClient('https://adm.com/api/service.php?wsdl');


    $headerbody = array('OrgId'=>'4AWisEr','OrgKey'=>'ikaroXajiD');
    $header = new SoapHeader('https://adm.com/api/service.php?wsdl','credentials',$headerbody);

    $client->__setSoapHeaders($header);

   $result = $client->emailExists($email);

   return $result;

1 个答案:

答案 0 :(得分:1)

只需尝试一下,我就没有出现名称空间错误:

<?php

namespace App\Http\Controllers;

use SoapClient;

class TestController extends Controller
{
    public function index()
    {
        $client = new SoapClient('https://adm.com/api/service.php?wsdl');
    }
}