在 PHP 中的 SoapServer 中的 SetClass 之后添加 SoapHeader

问题描述

我有一个在 $obj->setClass() 中设置的类来处理 SoapServer 中的请求。 但现在我需要在该类中设置一些soapHeader。 我如何在该类中设置 SoapHeader 或访问 SoapServer 对象?

server.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 对象中使用 addSoapHeader ,它将被 ->handle() 覆盖。

class sample { 
 public function test() {  
global $svr;
$svr->addSoapHedaer($soapHeader); 
   // add some soapHeader to $svr object
 }
}

您需要在使用 SoapHeader PHP 原生类之前制作 $soapHeader

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)