server009.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --TEST--
  2. SOAP Server 9: setclass and setpersistence(SOAP_PERSISTENCE_SESSION)
  3. --SKIPIF--
  4. <?php
  5. require_once('skipif.inc');
  6. if (!extension_loaded('session')) {
  7. die('skip this test needs session extension');
  8. }
  9. ?>
  10. --INI--
  11. session.auto_start=1
  12. session.save_handler=files
  13. --FILE--
  14. <?php
  15. class foo {
  16. private $sum = 0;
  17. function Sum($num) {
  18. return $this->sum += $num;
  19. }
  20. }
  21. $server = new soapserver(null,array('uri'=>"http://testuri.org"));
  22. $server->setclass("foo");
  23. $server->setpersistence(SOAP_PERSISTENCE_SESSION);
  24. ob_start();
  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:Sum xmlns:ns1="http://testuri.org">
  35. <num xsi:type="xsd:int">5</num>
  36. </ns1:Sum>
  37. </SOAP-ENV:Body>
  38. </SOAP-ENV:Envelope>
  39. EOF;
  40. $server->handle($HTTP_RAW_POST_DATA);
  41. ob_clean();
  42. $HTTP_RAW_POST_DATA = <<<EOF
  43. <?xml version="1.0" encoding="ISO-8859-1"?>
  44. <SOAP-ENV:Envelope
  45. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  46. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  47. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  48. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  49. xmlns:si="http://soapinterop.org/xsd">
  50. <SOAP-ENV:Body>
  51. <ns1:Sum xmlns:ns1="http://testuri.org">
  52. <num xsi:type="xsd:int">3</num>
  53. </ns1:Sum>
  54. </SOAP-ENV:Body>
  55. </SOAP-ENV:Envelope>
  56. EOF;
  57. $server->handle($HTTP_RAW_POST_DATA);
  58. ob_end_flush();
  59. echo "ok\n";
  60. ?>
  61. --EXPECT--
  62. <?xml version="1.0" encoding="UTF-8"?>
  63. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:SumResponse><return xsi:type="xsd:int">8</return></ns1:SumResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
  64. ok