函数(“___ setSoapHeaders”)不是此服务的有效方法

时间:2014-03-06 14:40:10

标签: php soap soap-client

您好我正在尝试使用Google adWords API并且刚开始我遇到了一个“无效方法”的问题,即使我正确地关注所有内容(我相信)这是我的代码:

ini_set("soap.wsdl_cache_enabled",0);

class adwords {

    protected $server = "###";
    protected $version = "###";
    protected $email = "###";
    protected $password = "###";
    protected $auth_key = "###";
    protected $dev_key = "###";
    protected $ua = "###";
    protected $client_id = ###;

    public function __construct() {
        $this->campaign_service();
    }

    public function campaign_service() {

        $service = "CampaignService";
        $options = array(
            'encoding' => 'utf-8',
            'features' => SOAP_SINGLE_ELEMENT_ARRAYS
        );
        $wsdl = "{$this->server}/{$this->version}/{$service}?wsdl";
        $namespace = "###";
        $header = array(
            'authToken' => $this->auth_key,
            'clientCustomerId' => $this->client_id,
            'userAgent' => $this->ua,
            'developerToken' => $this->dev_key
        );

        $client = new SoapClient($wsdl,$options);
        $headers = new SoapHeader($namespace,"RequestHeader",$header,false);
        $client->___setSoapHeaders($headers);

    }        
}

这是我回来的错误:

PHP致命错误:未捕获的SoapFault异常:[客户端]函数(“___ setSoapHeaders”)不是此服务的有效方法

我错过了什么吗?根据{{​​3}},这是一种有效的方法。还有更多我尝试搜索我能想到的一切,但找不到任何东西。任何帮助是极大的赞赏!我顺便运行PHP 5.3.3。

1 个答案:

答案 0 :(得分:1)

__ setSoapHeaders,只有两个下划线,而不是三个。