doutusheng5879 2019-03-06 13:25 采纳率: 0%
浏览 70

SoapFault:看起来我们没有XML文档Magento和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?

  • 写回答

1条回答 默认 最新

  • dpdt79577 2019-03-06 15:51
    关注

    Try this one, structure your request as follows

        $options = array('trace'=> true,'exceptions' => true);            
        $client  = new \SoapClient('https://www.example.com?wsdl',$options);
    
        $params = new \stdClass();
        $params->key1 = 'XXXXXX';
        $params->Key2 = 'XXXXX';
        $soapVar = new \SoapVar($params,SOAP_ENC_OBJECT);
    
        $header = new \SoapHeader('https://www.example?wsdl','credentials',$soapVar);
    
        $client->__setSoapHeaders(array($header));
    
    
        $result=$client->login(function parameters here);
    

    Cheers!!!

    评论

报告相同问题?

悬赏问题

  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表