【问题标题】:Zend soap call for method with hyphenZend soap 调用带有连字符的方法
【发布时间】:2011-12-06 10:25:32
【问题描述】:

我使用 Zend 框架重写了 soap 客户端文件。

这是旧方法。这是工作。

function getBassaService(){
    global $service;
    $h="127.0.0.1";
    $p="8000";

    if($service==null){
        $service = new SoapClient("/test/php/bassa.wsdl", array(
        "soap_version"   => SOAP_1_2,
        "trace"      => 1,
        "exceptions" => 1,
        "location" => "http://".$h.":".$p));
    }
    return $service;
}

function getAllDownloads(){
    global $service;
    $client = getService();
    try{
        $results = $client->__soapCall("list-all", array());
    }catch(SoapFault $e){
        print($e->faultstring);     
    }

    return $result;
}

这是我的新代码。我使用 Zend_Soap_Client。

    const HOST = "127.0.0.1";       
    const PORT = "8095";

    protected $_client; 

    public function __construct()
    {           
        $this->_client = new Zend_Soap_Client(APPLICATION_PATH ."/services/bassa.wsdl",
        array(
            "soap_version" => SOAP_1_2,
            "uri" => "http://". self::HOST .":". self::PORT
            )
        );
    }

    public function getAllDownloads()
    {
        $result = $this->_client->list-all();
        return $result;
    }

我的肥皂服务器有list-all 方法。我想要对该方法的肥皂调用。但是出现了以下错误。因为方法名称有连字符。

Notice: Undefined property: Zend_Soap_Client::$list in /home/dinuka/workspace/testzend/application/services/SoapClient.php on line 57

Fatal error: Call to undefined function all() in /home/dinuka/workspace/testzend/application/services/SoapClient.php on line 57

我是如何解决的。请帮我。

【问题讨论】:

    标签: php zend-framework soap zend-soap


    【解决方案1】:

    奇怪。那应该可以。这可能是 ZF 框架中的一个错误。也许它正在尝试将函数名转换为带有变量的驼峰式函数名。

    尝试通过调用直接使用魔法函数:

    $this->_client->__call('list-all', array('param1' => $param1))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-29
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 2012-03-01
      • 2016-06-15
      • 2021-10-04
      相关资源
      最近更新 更多