Re: Accessing SOAP Headers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

-- 
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux