php - 在 PHP 的 SoapServer 中的 SetClass 之后添加 SoapHeader
问题描述
我有一个在 $obj->setClass() 中设置的类来处理 SoapServer 中的请求。但现在我需要在该类中设置一些soapHeader。我如何在该类中设置 SoapHeader 或访问 SoapServer 对象?
服务器.php
$svr = new SoapServer('http://localhost?wsdl');
$svr->setClass("SampleClass");
$svr->handle();
样本类
class sample {
public function test() {
// add some soapHeader to $svr object
}
}
--编辑--找到了解决方案:)
只需在处理程序类函数中创建 $svr 全局并使用 addSoapHeader 。如果您在 svr object 中使用 addSoapHeader,它将被 ->handle() 覆盖。
class sample {
public function test() {
global $svr;
$svr->addSoapHedaer($soapHeader);
// add some soapHeader to $svr object
}
}
您需要在使用 SoapHeader PHP 本机类之前制作 $soapHeader
解决方案
推荐阅读
- html - 安装 MongoDB 时破坏了我的终端
- javascript - eslint 解析错误:使用 firebase 设置后无法读取文件 'c:\user\repo\ts-project\tsconfig.json'
- qt - 如何在 Qt 中使用 vlc-qt libvlc 从视频中读取元数据
- angular-material - 自定义日期过滤器没有返回任何东西 Angular 8
- routes - 使用aapanel作为控制面板的Laravel 8路由无法在vps上运行
- python - 如何抑制熊猫数据框?
- create-react-app - CRA v4:__WB_MANIFEST 是如何设置的?它是可定制的吗?
- python - Python 彭博 xbbg
- sql - Oracle 替换一些重复的字符(非数字)
- spring-webflux - Spring webflux - 验证查询参数和路径参数