xref: /PHP-8.4/ext/soap/tests/bugs/bug50675.phpt (revision e1b59e9e)
1--TEST--
2Bug #50675 SoapClient can't handle object references correctly.
3--EXTENSIONS--
4soap
5--FILE--
6<?php
7
8class TestSoapClient extends SoapClient {
9  function __doRequest($request, $location, $action, $version, $one_way = 0): string {
10    return <<<EOF
11<?xml version="1.0" encoding="UTF-8"?>
12<soapenv:Envelope
13xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
14xmlns:xsd="http://www.w3.org/2001/XMLSchema"
15xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
16    <soapenv:Body>
17        <soapenv:Fault>
18            <faultcode>soapenv:Server.userException</faultcode>
19            <faultstring>service.EchoServiceException</faultstring>
20            <detail>
21                <service.EchoServiceException xsi:type="ns1:EchoServiceException" xmlns:ns1="urn:service.EchoService">
22                    <intParameter xsi:type="xsd:int">105</intParameter>
23                    <parameter xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">string param</parameter>
24                </service.EchoServiceException>
25                <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">steckovic</ns2:hostname>
26            </detail>
27        </soapenv:Fault>
28    </soapenv:Body>
29</soapenv:Envelope>
30EOF;
31    }
32}
33
34ini_set('soap.wsdl_cache_enabled', 0);
35
36$parameters = [
37    'trace' => 1,
38    'exceptions' => 0,
39];
40$client = new TestSoapClient(__DIR__ . '/bug50675.wsdl', $parameters);
41
42$person = new stdClass();
43$person->name = 'name';
44
45$result = $client->echoPerson($person, $person);
46
47print($client->__getLastRequest());
48?>
49--EXPECT--
50<?xml version="1.0" encoding="UTF-8"?>
51<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://service" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:service.EchoService" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:echoPerson><p xsi:type="ns2:Person" id="ref1"><name xsi:type="SOAP-ENC:string">name</name></p><p2 href="#ref1"/></ns1:echoPerson></SOAP-ENV:Body></SOAP-ENV:Envelope>
52