2

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?

1 Answer 1

0

Try following way:

<?php
try {
    $user = 'username';
    $password = 'password';
    $proxy = new SoapClient('https://shop.com/api/v2_soap/?wsdl');

    $sessionId = $proxy->login($user, $password);
    var_dump($sessionId);
} catch (Exception $e) {
    echo $e->getMessage();
}
2
  • I trying with this code, but i receive this other error: Error cannot find parameter Mar 6, 2019 at 18:22
  • but if I transform the parameters into an array object, the previous error will persist Mar 6, 2019 at 18:25

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.