server010.phpt 2.0 KB

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