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