Php/docs/soapclient.setsoapheaders

来自菜鸟教程
跳转至:导航、​搜索

SoapClient::__setSoapHeaders

(PHP 5 >= 5.0.5, PHP 7)

SoapClient::__setSoapHeadersSets SOAP headers for subsequent calls


说明

public SoapClient::__setSoapHeaders ([ mixed $soapheaders ] ) : bool

Defines headers to be sent along with the SOAP requests.

Note:

Calling this method will replace any previous values.

参数

soapheaders
The headers to be set. It could be SoapHeader object or array of SoapHeader objects. If not specified or set to null, the headers will be deleted.


返回值

成功时返回 true, 或者在失败时返回 false


范例

Example #1 SoapClient::__setSoapHeaders() example

<?php$client = new SoapClient(null, array('location' => "http://localhost/soap.php%22,                                     'uri'      => "http://test-uri/%22));$header = new SoapHeader('http://soapinterop.org/echoheader/',                             'echoMeStringRequest',                            'hello world');$client->__setSoapHeaders($header);$client->__soapCall("echoVoid", null);?>

Example #2 Set Multiple Headers

<?php$client = new SoapClient(null, array('location' => "http://localhost/soap.php%22,                                     'uri'      => "http://test-uri/%22));$headers = array();$headers[] = new SoapHeader('http://soapinterop.org/echoheader/',                             'echoMeStringRequest',                            'hello world');$headers[] = new SoapHeader('http://soapinterop.org/echoheader/',                             'echoMeStringRequest',                            'hello world again');$client->__setSoapHeaders($headers);$client->__soapCall("echoVoid", null);?>