server013.phpt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. --TEST--
  2. SOAP Server 13: array handling
  3. --EXTENSIONS--
  4. soap
  5. --FILE--
  6. <?php
  7. function Sum($a) {
  8. $sum = 0;
  9. if (is_array($a)) {
  10. foreach($a as $val) {
  11. $sum += $val;
  12. }
  13. }
  14. return $sum;
  15. }
  16. $server = new soapserver(null,array('uri'=>"http://testuri.org"));
  17. $server->addfunction("Sum");
  18. $HTTP_RAW_POST_DATA = <<<EOF
  19. <?xml version="1.0" encoding="UTF-8"?>
  20. <SOAP-ENV:Envelope
  21. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  22. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  23. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  24. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  25. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  26. <SOAP-ENV:Body xmlns:ns1="http://linuxsrv.home/~dmitry/soap/">
  27. <ns1:sum>
  28. <param0 SOAP-ENC:arrayType="xsd:int[2]" xsi:type="SOAP-ENC:Array">
  29. <val xsi:type="xsd:int">3</val>
  30. <val xsi:type="xsd:int">5</val>
  31. </param0>
  32. </ns1:sum>
  33. </SOAP-ENV:Body>
  34. </SOAP-ENV:Envelope>
  35. EOF;
  36. $server->handle($HTTP_RAW_POST_DATA);
  37. echo "ok\n";
  38. ?>
  39. --EXPECT--
  40. <?xml version="1.0" encoding="UTF-8"?>
  41. <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>
  42. ok