xref: /PHP-7.3/ext/soap/tests/typemap010.phpt (revision 782352c5)
1--TEST--
2SOAP typemap 10: SoapServer support for typemap's to_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:dotest2>
18<dotest2 xsi:type=\"xsd:string\">???</dotest2>
19</ns1:dotest2>
20 </env:Body>
21<env:Header/>
22</env:Envelope>";
23
24function book_to_xml($book) {
25	throw new SoapFault("Server", "Conversion Fault");
26}
27
28class test{
29	function dotest2($str){
30		$book = new book;
31		$book->a = "foo";
32		$book->b = "bar";
33		return $book;
34	}
35}
36
37class book{
38	public $a="a";
39	public $b="c";
40
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		                         "to_xml"    => "book_to_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 Fault</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
58ok
59