php-src/ext/soap/tests/typemap007.phpt

57 lines
1.6 KiB
PHP
Executable File

--TEST--
SOAP Typemap 7: SoapClient support for typemap's from_xml() (without WSDL)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
class TestSoapClient extends SoapClient{
function __doRequest($request, $location, $action, $version) {
return <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<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:dotest2Response><res xsi:type="ns1:book">
<a xsi:type="xsd:string">foo</a>
<b xsi:type="xsd:string">bar</b>
</res>
</ns1:dotest2Response></SOAP-ENV:Body></SOAP-ENV:Envelope>
EOF;
}
}
class book{
public $a="a";
public $b="c";
}
function book_from_xml($xml) {
$sxe = simplexml_load_string($xml);
$obj = new book;
$obj->a = (string)$sxe->a;
$obj->b = (string)$sxe->b;
return $obj;
}
$options=Array(
'uri' => 'http://schemas.nothing.com',
'location' => 'test://',
'actor' => 'http://schemas.nothing.com',
'typemap' => array(array("type_ns" => "http://schemas.nothing.com",
"type_name" => "book",
"from_xml" => "book_from_xml"))
);
$client = new TestSoapClient(NULL, $options);
$ret = $client->dotest2("???");
var_dump($ret);
echo "ok\n";
?>
--EXPECTF--
object(book)#%d (2) {
["a"]=>
string(3) "foo"
["b"]=>
string(3) "bar"
}
ok