bug50762.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Bug #50762 (in WSDL mode Soap Header handler function only being called if defined in WSDL)
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. class testSoap {
  8. private $auth;
  9. public function authToken($token){
  10. $this->auth=true;
  11. }
  12. public function testHeader($param){
  13. return 'header handler ' . ($this->auth ? 'called' : 'not called');
  14. }
  15. }
  16. class LocalSoapClient extends SoapClient {
  17. function __construct($wsdl, $options) {
  18. parent::__construct($wsdl, $options);
  19. $this->server = new SoapServer($wsdl, $options);
  20. $this->server->setObject(new testSoap());
  21. }
  22. function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
  23. ob_start();
  24. $this->server->handle($request);
  25. $response = ob_get_contents();
  26. ob_end_clean();
  27. return $response;
  28. }
  29. }
  30. $cl = new LocalSoapClient(__DIR__.'/bug50762.wsdl', array('cache_wsdl'=>WSDL_CACHE_NONE, 'trace'=>true));
  31. class authToken{
  32. public function __construct($token){
  33. $this->authToken=$token;
  34. }
  35. }
  36. $cl->__setSoapHeaders(array(new SoapHeader('http://sova.pronto.ru/', 'authToken', new authToken('tokendata'))));
  37. echo $cl->testHeader('param') . PHP_EOL;
  38. ?>
  39. --EXPECT--
  40. header handler called