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