Re: [SOAP] Accessing SOAP Headers

From: Date: Mon, 11 Apr 2005 15:48:51 +0000
Subject: Re: [SOAP] Accessing SOAP Headers
References: 1  Groups: php.soap 
Request: Send a blank email to php-soap+get-1847@lists.php.net to get a copy of this message
On Mon, 11 Apr 2005, Alex Stansfield wrote: > I saw a post mentioning the example in ext/soap/tests/soap12 but have to > say it wasn't quite what I expected and didn't make much sense to me. I > wasn't sure if perhaps this is due to the way I use the server > (functions rather than class - see above). I have not done this, but from poking around the example code, I would think this would work: Input XML: <?xml version='1.0' ?> <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <test:requiredHeader xmlns:test="http://example.org/ts-tests" env:mustUnderstand="true">foo</test:requiredHeader> </env:Header> <env:Body> <test:echoHeader xmlns:test="http://example.org/ts-tests"> </test:echoHeader> </env:Body> </env:Envelope> Server PHP Code: function requiredHeader($h) { // do something with the header // store result in $GLOBALS array } function echoHeader() { // pull result from $GLOABLS array } $s = new SOAPServer('my.wsdl'); $s->addFunction('requiredHeader'); $s->addFunction('echoHeader'); $s->handle(); One advantage of using a class instead of methods is that you can stash header data (or other shared information) as object properties instead of using the global namespace. This is cribbed from T32.phpt. -adam -- adam@trachtenberg.com | http://www.trachtenberg.com author of o'reilly's "upgrading to php 5" and "php cookbook" avoid the holiday rush, buy your copies today!

« previous php.soap (#1847) next »