xref: /PHP-5.4/ext/soap/tests/bugs/bug36575.phpt (revision 610c7fbe)
1--TEST--
2Bug #36575 (Incorrect complex type instantiation with hierarchies)
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9abstract class CT_A1 {
10	public $var1;
11}
12
13class CT_A2 extends CT_A1 {
14	public $var2;
15}
16
17class CT_A3 extends CT_A2 {
18	public $var3;
19}
20
21// returns A2 in WSDL
22function test( $a1 ) {
23	$a3 = new CT_A3();
24	$a3->var1 = $a1->var1;
25	$a3->var2 = "var two";
26	$a3->var3 = "var three";
27	return $a3;
28}
29
30$classMap = array("A1" => "CT_A1", "A2" => "CT_A2", "A3" => "CT_A3");
31
32$client = new SoapClient(dirname(__FILE__)."/bug36575.wsdl", array("trace" => 1, "exceptions" => 0, "classmap" => $classMap));
33$a2 = new CT_A2();
34$a2->var1 = "one";
35$a2->var2 = "two";
36$client->test($a2);
37
38$soapRequest = $client->__getLastRequest();
39
40echo $soapRequest;
41
42$server = new SoapServer(dirname(__FILE__)."/bug36575.wsdl", array("classmap" => $classMap));
43$server->addFunction("test");
44$server->handle($soapRequest);
45echo "ok\n";
46?>
47--EXPECT--
48<?xml version="1.0" encoding="UTF-8"?>
49<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:test.soap#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:test.soap.types#" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:test><a1 xsi:type="ns2:A2"><var1 xsi:type="xsd:string">one</var1><var2 xsi:type="xsd:string">two</var2></a1></ns1:test></SOAP-ENV:Body></SOAP-ENV:Envelope>
50<?xml version="1.0" encoding="UTF-8"?>
51<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:test.soap#" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:test.soap.types#" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:testResponse><result xsi:type="ns2:A3"><var1 xsi:type="xsd:string">one</var1><var2 xsi:type="xsd:string">var two</var2><var3 xsi:type="xsd:string">var three</var3></result></ns1:testResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
52ok
53