5

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

10

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:

http://php.net/manual/en/soapclient.soapclient.php

1
  • 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 May 9 '18 at 9:51
0

You can use zend soap like this.

$api = new \Zend\Soap\Client(NULL, $options);

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.