Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- SOAP Typemap 8: SoapClient support for typemap's to_xml() (without WSDL, using So..

Decoded Output download

--TEST--
SOAP Typemap 8: SoapClient support for typemap's to_xml() (without WSDL, using SoapVar)
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--FILE--
<?php
class TestSoapClient extends SoapClient{
  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
        echo $request;
        exit;
    }
}

class book{
    public $a="a";
    public $b="c";

}

function book_to_xml($book) {
    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>';
}

$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",
                                  "to_xml"  => "book_to_xml"))
        );

$client = new TestSoapClient(NULL, $options);
$book = new book();
$book->a = "foo";
$book->b = "bar";
$ret = $client->dotest(new SoapVar($book, null, "book", "http://schemas.nothing.com"));
var_dump($ret);
echo "ok
";
?>
--EXPECT--
<?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: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>

Did this file decode correctly?

Original Code

--TEST--
SOAP Typemap 8: SoapClient support for typemap's to_xml() (without WSDL, using SoapVar)
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--FILE--
<?php
class TestSoapClient extends SoapClient{
  function __doRequest($request, $location, $action, $version, $one_way = 0): ?string {
        echo $request;
        exit;
    }
}

class book{
    public $a="a";
    public $b="c";

}

function book_to_xml($book) {
    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>';
}

$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",
                                  "to_xml"  => "book_to_xml"))
        );

$client = new TestSoapClient(NULL, $options);
$book = new book();
$book->a = "foo";
$book->b = "bar";
$ret = $client->dotest(new SoapVar($book, null, "book", "http://schemas.nothing.com"));
var_dump($ret);
echo "ok\n";
?>
--EXPECT--
<?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: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>

Function Calls

None

Variables

None

Stats

MD5 701e66892d2b60a5e9709677840ae788
Eval Count 0
Decode Time 94 ms