Adding a header to all SOAP requests transparently
| From: | Mike Carter | Date: | Wed, 28 Apr 2004 09:42:12 +0000 |
| Subject: | Adding a header to all SOAP requests transparently | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-1505@lists.php.net to get a copy of this message | ||
Hi,
For each webservice call I need to pass a token in the SOAP envelope header.
This is done using:-
$ourHeader = new SOAP_Header('TokenHeader', 'Struct',
array('InnerToken' =>
$this->userToken), false);
$ourHeader->attributes['xmlns'] =
$GLOBALS['g_ps']['MedVisor']['serviceNamespace'];
$this->addHeader($ourHeader);
I would like this code to be automatically added upon each webservice method
call without me having to duplicate code.
So, I've created a class for my custom webservice methods. This new class
extends the SOAP_Client class. All my webservices now extend my custom WS
class.
In the constructor I call the addHeader() above.
This works fine for the first WS call.
If I then call a subsequent webservice method in the same class, the header
is not sent! It seems to get discarded after the first use of
SOAP_Client::call() method.
Is this a bug or have I created my class architecture incorrectly to achieve
what I want to do?
Regards,
--
Mike C
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________