I am trying to make soap call to get data from 3rd party website. How can i use soap api call in magento2 ?

2 Answers 2


Inject \Magento\Framework\Webapi\Soap\ClientFactory in the class where you need it:

public function __construct(\Magento\Framework\Webapi\Soap\ClientFactory $soapClientFactory)
    $this->soapClientFactory = $soapClientFactory;

Then use it to instantiate a SoapClient instance:

$soapClient = $this->soapClientFactory->create($wsdl, $options);

For the parameters $wsdl and $options as well as usage examples, please refer to the PHP documentation:


  • hi Fabian, i tried the code and then discovered, a missing "create" should you now "create it", like $soapClient = $this->soapClientFactory->create( $wsdl, $options );
    – Evrijn
    Commented May 9, 2018 at 9:51

You can use zend soap like this.

$api = new \Zend\Soap\Client(NULL, $options);
  • For the one who's looking this in 2024, please note the \Zend\Soap\Client is removed since Magento 2.4.6. You should use \Laminas\Soap\Client instead.
    – PY Yick
    Commented Jun 7 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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