xref: /PHP-8.4/ext/soap/tests/server030.phpt (revision 7f2f0c00)
1--TEST--
2SOAP Server 30: Handling classes which extend the SPL ArrayObject or ArrayIterator as arrays in wsdl mode
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9class ItemArray extends ArrayObject {
10
11}
12
13class Item {
14    public $text;
15}
16
17class handlerClass {
18    public function getItems()
19    {
20        $items = new ItemArray(array());
21
22        for ($i = 0; $i < 10; $i++) {
23            $item = new Item();
24            $item->text = 'text'.$i;
25
26            $items[] = $item;
27        }
28
29        return $items;
30    }
31}
32
33$server = new SoapServer(__DIR__."/server030.wsdl");
34$server->setClass('handlerClass');
35
36$HTTP_RAW_POST_DATA = <<<EOF
37<?xml version="1.0" encoding="ISO-8859-1"?>
38<SOAP-ENV:Envelope
39  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
40  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
41  <SOAP-ENV:Body>
42    <getItems/>
43  </SOAP-ENV:Body>
44</SOAP-ENV:Envelope>
45EOF;
46
47$server->handle($HTTP_RAW_POST_DATA);
48echo "ok\n";
49?>
50--EXPECT--
51<?xml version="1.0" encoding="UTF-8"?>
52<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>
53ok
54