xref: /PHP-7.3/ext/soap/tests/typemap009.phpt (revision 782352c5)
1--TEST--
2SOAP typemap 9: SoapServer support for typemap's from_xml() (SoapFault)
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
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 <ns1:dotest>
18  <book xsi:type=\"ns1:book\">
19    <a xsi:type=\"xsd:string\">foo</a>
20    <b xsi:type=\"xsd:string\">bar</b>
21</book>
22</ns1:dotest>
23 </env:Body>
24<env:Header/>
25</env:Envelope>";
26
27function book_from_xml($xml) {
28	throw new SoapFault("Server", "Conversion Failed");
29}
30
31class test{
32	function dotest($book){
33		$classname=get_class($book);
34		return "Object: ".$classname. "(".$book->a.",".$book->b.")";
35	}
36}
37
38class book{
39	public $a="a";
40	public $b="c";
41
42}
43$options=Array(
44		'actor'   =>'http://schemas.nothing.com',
45		'typemap' => array(array("type_ns"   => "http://schemas.nothing.com",
46		                         "type_name" => "book",
47		                         "from_xml"  => "book_from_xml"))
48		);
49
50$server = new SoapServer(dirname(__FILE__)."/classmap.wsdl",$options);
51$server->setClass("test");
52$server->handle($HTTP_RAW_POST_DATA);
53echo "ok\n";
54?>
55--EXPECT--
56<?xml version="1.0" encoding="UTF-8"?>
57<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Conversion Failed</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
58ok
59