SoapClient set custom HTTP Header

后端 未结 5 1916
傲寒
傲寒 2020-12-30 06:36

I am doing some work writing a PHP-based SOAP client application that uses the SOAP libraries native to PHP5. I need to send a an HTTP cookie and an additional HTTP header

5条回答
  •  一向
    一向 (楼主)
    2020-12-30 07:10

    its easy to implement in nuSoap:

    NUSOAP.PHP

    add to class nusoap_base:

    var additionalHeaders = array();
    

    then goto function send of the same class

    and add

    foreach ($this->additionalHeaders as $key => $value) {
        $http->setHeader($key, $value);
    }
    

    somewhere around (just before)

    $http->setSOAPAction($soapaction); (line 7596)
    

    now you can easy set headers:

    $soapClient = new nusoap_client('wsdl adress','wsdl');
    $soapClient->additionalHeaders = array('key'=>'val','key2'=>'val');
    

提交回复
热议问题