1

I need to make a SoapClient new SoapClient call from within one of my Models for a validation rule. When I create the new SoapClient instance class in my Model function I'm getting this error message:

Fatal error: Class 'Craft\SoapClient' not found in...

I get the same error message whatever file Model/Service/Controller i put it in.

public function validateVatNumber()
{
    $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
}

Could anyone let me know what I should do to be able to make these calls? I'm guessing I somehow need to "break free" from the Craft namespace.

Thank you

1

You need to backslash the class to tell it to look in the global namespace like so:

public function validateVatNumber()
{
    $client = new \SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl");
}

You can read on the basics of PHP namespacing here: http://php.net/manual/en/language.namespaces.basics.php

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.