略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: SoapServer::addSoapHeader

2024-11-14

SoapServer::addSoapHeader

(PHP 5 >= 5.1.3, PHP 7, PHP 8)

SoapServer::addSoapHeaderAdd a SOAP header to the response

说明

public SoapServer::addSoapHeader(SoapHeader $header): void

Adds a SOAP header to be returned with the response to the current request.

参数

header

The header to be returned.

返回值

没有返回值。

add a noteadd a note

User Contributed Notes 1 note

up
0
vladimir at bashkirtsev dot com
5 years ago
Notably addSoapHeaders() must be called within handling class/object.

If you call addSoapHeaders() like this:

$server = new SoapServer("some.wsdl");
$server->setObject(new Service());
$server->addSoapHeaders(new SoapHeader("ns", "Header", "value"));
$server->handle();

Your SOAP header will not be added to the server response as it will be overwritten by result of handle() function.

If you want to add SOAP headers to the resulting response you should make $server global/static variable and then call addSoapHeaders() from within of the method of Service class which will handle the request.

官方地址:https://www.php.net/manual/en/soapserver.addsoapheader.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3