如何在PHP中为SOAP客户端正确设置Cookie /标头?

时间:2018-11-13 17:08:42

标签: php soap soap-client php-5.3

我正在尝试按照我发现的几个主题(请参阅本文结尾处的列表)启用对SOAP调用的xDebug支持,这是我到目前为止所做的:

$this->_client_soap = new SoapClient(
    $this->ecase_wsdl,
    array(
        'trace'        => 1,
        'exceptions'   => true,
        'soap_version' => SOAP_1_1,
        'cache_wsdl'   => WSDL_CACHE_NONE
    )
);

// Xdebug Support
$xdebug_remote_address = $this->CI->config->item('xdebug_remote_address');
$xdebug_cookie         = $this->CI->config->item('xdebug_cookie');

if ($xdebug_remote_address && $xdebug_cookie) {
    $this->_client_soap->setCookie('X-Xdebug-Remote-Address', $xdebug_remote_address);
    $this->_client_soap->setCookie('Cookie', $xdebug_cookie);
}

$soap_string = $this->build_add_new_case_xml_string();

$ecase_response = $this->_client_soap->__doRequest(
    $soap_string,
    $this->ecase_wsdl,
    $this->service,
    SOAP_1_1
);

但是我收到以下SoapFault错误消息:

Function ("setCookie") is not a valid method for this service

我在这里想念的是什么?设置Cookie /标题的正确方法是什么?我的PHP版本是5.3.3

之前检查过的文章:

1 个答案:

答案 0 :(得分:0)

http://php.net/manual/en/soapclient.setcookie.php

但是看到函数定义为魔术,您不应直接调用它。

保重。