server004.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. SOAP Server 4: addfunctions
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. function Add($x,$y) {
  8. return $x+$y;
  9. }
  10. function Sub($x,$y) {
  11. return $x-$y;
  12. }
  13. $server = new soapserver(null,array('uri'=>"http://testuri.org"));
  14. $server->addfunction(array("Sub","Add"));
  15. $HTTP_RAW_POST_DATA = <<<EOF
  16. <?xml version="1.0" encoding="ISO-8859-1"?>
  17. <SOAP-ENV:Envelope
  18. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  19. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  20. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  21. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  22. xmlns:si="http://soapinterop.org/xsd">
  23. <SOAP-ENV:Body>
  24. <ns1:Add xmlns:ns1="http://testuri.org">
  25. <x xsi:type="xsd:int">22</x>
  26. <y xsi:type="xsd:int">33</y>
  27. </ns1:Add>
  28. </SOAP-ENV:Body>
  29. </SOAP-ENV:Envelope>
  30. EOF;
  31. $server->handle($HTTP_RAW_POST_DATA);
  32. echo "ok\n";
  33. ?>
  34. --EXPECT--
  35. <?xml version="1.0" encoding="UTF-8"?>
  36. <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:AddResponse><return xsi:type="xsd:int">55</return></ns1:AddResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
  37. ok