mohsen shahbazi
mohsen shahbazi

Reputation: 13

add SoapHeader after SetClass in SoapServer in PHP

i have a class that set in $obj->setClass() to handle requests in SoapServer . but now i need to set some soapHeader inside that class. How i can set SoapHeader inside that class or access the SoapServer Object ?

server.php

$svr = new SoapServer('http://localhost?wsdl');
$svr->setClass("SampleClass");
$svr->handle();

SampleClass

class sample { 
 public function test() { 
   // add some soapHeader to $svr object
 }
}

--Edit-- found the solution :)

just make $svr global inside the handler class functions and using addSoapHeader . if you use addSoapHeader in svr object , it will be overwriten with ->handle() .

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

you need to make $soapHeader before with SoapHeader PHP native class

Upvotes: 1

Views: 87

Answers (0)

Related Questions