Skip to content

SoapFault: looks like we got no XML document – Magento and laravel

I am with a problem in my application Laravel, when i use the SoapClient, for example my_object_soap->login(); returned this error:

Fatal error: Uncaught SoapFault exception: [Client] looks like we got
no XML

I already tried several solutions that I researched in google and here, but I did not solve my problem.

my code follows:

    ini_set("soap.wsdl_cache_enabled",0);
    ini_set("soap.wsdl_cache",0);
    ini_set("error_reporting",-1);
    ini_set("display_errors","On");

    $wsdl_url = "https://example.com/index.php/api/v2_soap/index/?wsdl";
    $apiAuth = new stdClass();
    $apiAuth->username = trim("myusermagento");
    $apiAuth->apiKey = trim("mykeymagento");

    try{
        $proxy = new SoapClient($wsdl_url,array('cache_wsdl' => WSDL_CACHE_NONE, 'trace' => true));
        $session = $proxy->login($apiAuth);
        $data = $session;
        $status = true;
        $responseStatus = 200;
    } catch(SoapFault $e) {
        $error = $e->getMessage();
        $data = $proxy->__getLastResponse();
        $status = false;
        $responseStatus = 500;
    }        

    return Response::json([
        'success' => $status, 
        'data' => $data,
        'erros'=> $error,
    ],$responseStatus);

I have no idea which a problem, when i tested in SoapUI, with this user and key, it’s alright, but in my app not.

My magento version app is 1.6.2, and my php is 7.2, I already tried to downgrade to php 5.6 because it could be incompatibility with the magento version and my php but it still did not work.

Can someone help me?