xref: /PHP-5.6/ext/soap/tests/typemap004.phpt (revision 610c7fbe)
1--TEST--
2SOAP Typemap 4: SoapClient support for typemap's to_xml()
3--SKIPIF--
4<?php require_once('skipif.inc'); ?>
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) {
11  		echo $request;
12  		exit;
13	}
14}
15
16class book{
17	public $a="a";
18	public $b="c";
19
20}
21
22function book_to_xml($book) {
23	return '<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><a xsi:type="xsd:string">'.$book->a.'!</a><b xsi:type="xsd:string">'.$book->b.'!</b></book>';
24}
25
26$options=Array(
27		'actor' =>'http://schemas.nothing.com',
28		'typemap' => array(array("type_ns"   => "http://schemas.nothing.com",
29		                         "type_name" => "book",
30		                         "to_xml"  => "book_to_xml"))
31		);
32
33$client = new TestSoapClient(dirname(__FILE__)."/classmap.wsdl",$options);
34$book = new book();
35$book->a = "foo";
36$book->b = "bar";
37$ret = $client->dotest($book);
38var_dump($ret);
39echo "ok\n";
40?>
41--EXPECT--
42<?xml version="1.0" encoding="UTF-8"?>
43<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:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:dotest><book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:book"><a xsi:type="xsd:string">foo!</a><b xsi:type="xsd:string">bar!</b></book></ns1:dotest></SOAP-ENV:Body></SOAP-ENV:Envelope>
44