xref: /php-src/ext/soap/tests/typemap011.phpt (revision 8ae4b560)
1--TEST--
2SOAP Typemap 11: SoapClient support for typemap's from_xml() (SoapFault)
3--EXTENSIONS--
4soap
5--INI--
6soap.wsdl_cache_enabled=0
7--FILE--
8<?php
9class TestSoapClient extends SoapClient{
10  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
11        return <<<EOF
12<?xml version="1.0" encoding="UTF-8"?>
13<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>
14<ns1:dotest2Response><res xsi:type="ns1:book">
15  <a xsi:type="xsd:string">foo</a>
16  <b xsi:type="xsd:string">bar</b>
17</res>
18</ns1:dotest2Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
19EOF;
20    }
21}
22
23class book{
24    public $a="a";
25    public $b="c";
26
27}
28
29function book_from_xml($xml) {
30    throw new SoapFault("Client", "Conversion Error");
31}
32
33$options=Array(
34        'actor' =>'http://schemas.nothing.com',
35        'typemap' => array(array("type_ns"   => "http://schemas.nothing.com",
36                                 "type_name" => "book",
37                                 "from_xml"  => "book_from_xml"))
38        );
39
40$client = new TestSoapClient(__DIR__."/classmap.wsdl",$options);
41try {
42    $ret = $client->dotest2("???");
43} catch (SoapFault $e) {
44    $ret = "SoapFault = " . $e->faultcode . " - " . $e->faultstring;
45}
46var_dump($ret);
47echo "ok\n";
48?>
49--EXPECT--
50string(37) "SoapFault = Client - Conversion Error"
51ok
52