SoapClient::__setSoapHeaders
PHP function
Edit on GitHub ✎
(PHP 5 >= 5.0.5, PHP 7, PHP 8)
Sets SOAP headers for subsequent calls
Description
SoapClient::__setSoapHeaders(SoapHeader|array|null $headers = null): bool
Defines headers to be sent along with the SOAP requests.
Note
Calling this method will replace any previous values.
Parameters
headersThe headers to be set. It could be
SoapHeaderobject or array ofSoapHeaderobjects. If not specified or set to null, the headers will be deleted.
Return Values
Success
Examples
SoapClient::__setSoapHeaders() example
php
<?php
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$header = new SoapHeader('http://soapinterop.org/echoheader/',
'echoMeStringRequest',
'hello world');
$client->__setSoapHeaders($header);
$client->__soapCall("echoVoid", null);
?>Set Multiple Headers
php
<?php
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$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);
?>