Advertisement
Guest User

Untitled

a guest
May 25th, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. class Foo {
  3.     protected $soap ;
  4.    
  5.     function __construct(SoapServer $soap) {
  6.         $this->soap = $soap;
  7.     }
  8.    
  9.   function __call($name, $args) {
  10.     if ($name == "test") {
  11.       return "Hello World";
  12.     } else {
  13.       return new SoapFault("Server","Function $name doesn't exist");
  14.     }
  15.   }
  16.  
  17.   function __destruct() {
  18.         $this->soap->addSoapHeader(new SoapHeader('answers', 'everything', 42));
  19.   }
  20. }
  21.  
  22. $server = new soapserver(null,array('uri'=>"http://testuri.org"));
  23. $server->setclass("Foo", $server);
  24.  
  25. $HTTP_RAW_POST_DATA = <<<EOF
  26. <?xml version="1.0" encoding="ISO-8859-1"?>
  27. <SOAP-ENV:Envelope
  28.   SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  29.   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  30.   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  31.   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  32.   xmlns:si="http://soapinterop.org/xsd">
  33.   <SOAP-ENV:Body>
  34.     <ns1:test xmlns:ns1="http://testuri.org" />
  35.   </SOAP-ENV:Body>
  36. </SOAP-ENV:Envelope>
  37. EOF;
  38.  
  39. $server->handle($HTTP_RAW_POST_DATA);
  40. echo "ok\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement