On Tue, 12 Apr 2005, Alex Stansfield wrote: > > 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(); > > I spotted this code before but it just confused me. Does this mean I > actually need to call the "requiredHeader" function from the soap client > in order to tell the server to read the header? I don't believe so. It does mean you need to call the "requiredHeader" function on the SOAP **server** in order to read the header. > I was hoping for something more along the lines where if the server > receives a SOAP message with a header it was automatically extracted. So > if I called a "ApplicationRequest($appid)" from the client the > ApplicationRequest function on the server would have access > automatically to whatever headers were supplied in the request. This is not the model that ext/soap uses. The SOAP functions/methods do not automatically get a copy of SOAP header data. Instead, you must create a special SOAP header function that gets called first. This function can process the header or store it someplace where your SOAP function can pick it up. This is one of the advantages of using the class-based approach to SOAPServer, as you can have your SOAP header methods store header data in object properties, for easy access from within SOAP body methods. If this is confusing, remember that PHP functions do not get a copy of HTTP header data. Data should be separated into the header for a reason -- usually because it requires some pre-processing or is logically distinct from the action required in the body. > So far all the PHP soap I've done has been pretty easy and straight > forward, I was hoping the headers would be no different. Is there > something I'm missing here in my understanding of the situation? Personally, I see this as relatively straight forward. It is a little more complex than what you've been doing before, but intermixing SOAP header and SOAP body content is more complex than just processing the SOAP body. Since not everyone always needs the SOAP header data with their SOAP body calls, it makes sense to keep these separate for both performance and logical reasons. It just means that if you need to combine them, there's a little more work for you to do. -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! -- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php