xref: /PHP-8.4/ext/soap/tests/bugs/bug32776.phpt (revision e1b59e9e)
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  private $server;
19
20  function __construct($wsdl, $options) {
21    parent::__construct($wsdl, $options);
22    $this->server = new SoapServer($wsdl, $options);
23    $this->server->addFunction('test');
24  }
25
26  function __doRequest($request, $location, $action, $version, $one_way = 0): string {
27    ob_start();
28    $this->server->handle($request);
29    $response = ob_get_contents();
30    ob_end_clean();
31    return $response;
32  }
33
34}
35
36$x = new LocalSoapClient(__DIR__."/bug32776.wsdl",array("trace"=>true,"exceptions"=>false));
37var_dump($x->test("Hello"));
38var_dump($d);
39var_dump($x->__getLastRequest());
40var_dump($x->__getLastResponse());
41echo "ok\n";
42?>
43--EXPECT--
44NULL
45string(5) "Hello"
46string(459) "<?xml version="1.0" encoding="UTF-8"?>
47<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>
48"
49string(0) ""
50ok
51