Girish Hosamani
Girish Hosamani

Reputation: 1203

Unable to create a SOAP Client object in ZF2

I am creating a zend SOAP Client object to call the WSDL functions.

Here is my controller code :

namespace Application\Controller;

use Zend\Mvc\Controller\AbstractActionController;

use Zend\View\Model\ViewModel;

use Zend\Soap\AutoDiscover;

use Zend\Soap\Client;

use Zend\Soap\Server;

use Zend\Soap\Wsdl;


class IndexController extends AbstractActionController
{
    public function indexAction()
    {


$client = new Zend\Soap\Client("some.wsdl", array('compression' => SOAP_COMPRESSION_ACCEPT));

        $result = $client->somefunction();


        echo $result;
        echo exit;
    }

My library files are /vendor/ZF2/library/Zend.

And controller is modules folder.

I have used the Zend\Soap\Client; in controller.

Getting the following error: Fatal error: Class 'Application\Controller\Zend\Soap\Client' not found in .../Controller/IndexController.php on line 25

How to resolve this?

Thanks in advance.

Upvotes: 0

Views: 1290

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

Because you have use Zend\Soap\Client; at the top of the file, you want:

$client = new Client("some.wsdl", array('compression' => SOAP_COMPRESSION_ACCEPT));

Upvotes: 1

Related Questions