xref: /PHP-8.1/ext/soap/tests/bugs/bug32776.phpt (revision 8ae4b560)
1--TEST--
2Bug #32776 (SOAP doesn't support one-way operations)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9
10$d = null;
11
12function test($x) {
13    global $d;
14    $d = $x;
15}
16
17class LocalSoapClient extends SoapClient {
18
19  function __construct($wsdl, $options) {
20    parent::__construct($wsdl, $options);
21    $this->server = new SoapServer($wsdl, $options);
22    $this->server->addFunction('test');
23  }
24
25  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
26    ob_start();
27    $this->server->handle($request);
28    $response = ob_get_contents();
29    ob_end_clean();
30    return $response;
31  }
32
33}
34
35$x = new LocalSoapClient(__DIR__."/bug32776.wsdl",array("trace"=>true,"exceptions"=>false));
36var_dump($x->test("Hello"));
37var_dump($d);
38var_dump($x->__getLastRequest());
39var_dump($x->__getLastResponse());
40echo "ok\n";
41?>
42--EXPECT--
43NULL
44string(5) "Hello"
45string(459) "<?xml version="1.0" encoding="UTF-8"?>
46<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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><SOAP-ENV:test><x xsi:type="xsd:string">Hello</x></SOAP-ENV:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
47"
48string(0) ""
49ok
50