xref: /PHP-7.3/ext/soap/tests/server006.phpt (revision 6ef92162)
1--TEST--
2SOAP Server 6: setclass with constructor
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--FILE--
6<?php
7class Foo {
8  private $str = "";
9
10  function __construct($str) {
11    $this->str = $str . " World";
12  }
13
14  function test() {
15    return $this->str;
16  }
17}
18
19$server = new soapserver(null,array('uri'=>"http://testuri.org"));
20$server->setclass("Foo","Hello");
21
22$HTTP_RAW_POST_DATA = <<<EOF
23<?xml version="1.0" encoding="ISO-8859-1"?>
24<SOAP-ENV:Envelope
25  SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
26  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
27  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
28  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
29  xmlns:si="http://soapinterop.org/xsd">
30  <SOAP-ENV:Body>
31    <ns1:test xmlns:ns1="http://testuri.org" />
32  </SOAP-ENV:Body>
33</SOAP-ENV:Envelope>
34EOF;
35
36$server->handle($HTTP_RAW_POST_DATA);
37echo "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:testResponse><return xsi:type="xsd:string">Hello World</return></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
42ok
43