I tried to get data from outside webservice. I got API url like http://wsq.check.com:50001/Services/appsspg.asmx/GetActionLogand the data for the function is $data = array("parameter1" => "1");. So, how could i get the data from that external webservice?

1 Answer 1


To access external webservice, you can use Zend HTTP Client class, using the below code:

protected $_httpClientFactory;

public function __construct(
    \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
) {
    $this->_httpClientFactory   = $httpClientFactory;

 * Function to create CURL Request to External Server
public function connect()
        $data['parameter1'] = 1;

        $client = $this->_httpClientFactory->create();
        $client->setConfig(['timeout' => 300]);
        $client->setHeaders(['Content-Type: application/json', 'Accept: application/json']);

        try {
            $responseBody = $client->request()->getBody();

            echo '<pre>';
        } catch (\Exception $e) {
            echo $e->getMessage();

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.