server009.phpt 2.1 KB

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