Symfony 2 SOAP CLIENT

10,723

...because your controller is in a namespace, so your call to instantiate SoapClient without the root slash tries to load that object from the current namespace.

App\Controller\SoapClient instead of SoapClient.

You can use a use statement at the top of your controller to bring it into scope. use SoapClient; and you'll be good to go.

Share:
10,723
M4xell
Author by

M4xell

Updated on June 04, 2022

Comments

  • M4xell
    M4xell almost 2 years

    Please tell me why i must put "\" before \SoapClient. When i delete "\", then i have a error.

    public function indexAction($name)
    {
    
        try {
                $client = new \SoapClient('some WSDL', array('trace' => 1));
                $a = array('Login'=>'1', 'Password'=>'1', 'LetterNo'=>'1');
                $response = $client->__soapCall('GetTracking', array($a));
                ladybug_dump($response->GetTrackingResult->Status);
            } catch (\SoapFault $e) {
                var_dump($e->getMessage(), $client->__getLastResponse()); die();
        }
        return array('response' => $response);
    }
    

    Thanks for help