server030.phpt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --TEST--
  2. SOAP Server 30: Handling classes which extend the SPL ArrayObject or ArrayIterator as arrays in wsdl mode
  3. --EXTENSIONS--
  4. soap
  5. --INI--
  6. soap.wsdl_cache_enabled=0
  7. --FILE--
  8. <?php
  9. class ItemArray extends ArrayObject {
  10. }
  11. class Item {
  12. public $text;
  13. }
  14. class handlerClass {
  15. public function getItems()
  16. {
  17. $items = new ItemArray(array());
  18. for ($i = 0; $i < 10; $i++) {
  19. $item = new Item();
  20. $item->text = 'text'.$i;
  21. $items[] = $item;
  22. }
  23. return $items;
  24. }
  25. }
  26. $server = new SoapServer(__DIR__."/server030.wsdl");
  27. $server->setClass('handlerClass');
  28. $HTTP_RAW_POST_DATA = <<<EOF
  29. <?xml version="1.0" encoding="ISO-8859-1"?>
  30. <SOAP-ENV:Envelope
  31. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  32. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  33. <SOAP-ENV:Body>
  34. <getItems/>
  35. </SOAP-ENV:Body>
  36. </SOAP-ENV:Envelope>
  37. EOF;
  38. $server->handle($HTTP_RAW_POST_DATA);
  39. echo "ok\n";
  40. ?>
  41. --EXPECT--
  42. <?xml version="1.0" encoding="UTF-8"?>
  43. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://testuri.org" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getItemsResponse><getItemsReturn SOAP-ENC:arrayType="ns1:Item[10]" xsi:type="ns1:ItemArray"><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text0</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text1</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text2</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text3</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text4</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text5</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text6</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text7</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text8</text></item><item xsi:type="ns1:Item"><text xsi:type="xsd:string">text9</text></item></getItemsReturn></ns1:getItemsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
  44. ok