xref: /PHP-8.2/ext/soap/tests/classmap001.phpt (revision 7f2f0c00)
1--TEST--
2SOAP Classmap 1: SoapServer support for classmap
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9$GLOBALS['HTTP_RAW_POST_DATA']="
10<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"
11    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
12    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
13    xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\"
14    xmlns:ns1=\"http://schemas.nothing.com\"
15>
16  <env:Body>
17 <dotest>
18  <book xsi:type=\"ns1:book\">
19    <a xsi:type=\"xsd:string\">Blaat</a>
20    <b xsi:type=\"xsd:string\">aap</b>
21</book>
22</dotest>
23 </env:Body>
24<env:Header/>
25</env:Envelope>";
26
27class test{
28    function dotest(book $book){
29        $classname=get_class($book);
30        return "Classname: ".$classname;
31    }
32}
33
34class book{
35    public $a="a";
36    public $b="c";
37
38}
39$options=Array(
40        'actor' =>'http://schema.nothing.com',
41        'classmap' => array('book'=>'book', 'wsdltype2'=>'classname2')
42        );
43
44$server = new SoapServer(__DIR__."/classmap.wsdl",$options);
45$server->setClass("test");
46$server->handle($GLOBALS['HTTP_RAW_POST_DATA']);
47echo "ok\n";
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://schemas.nothing.com" 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:dotestResponse><res xsi:type="xsd:string">Classname: book</res></ns1:dotestResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
52ok
53