从SoapVar转储XML字符串

时间:2019-06-11 13:10:33

标签: php soap

是否可以通过其他方式从SoapVar输出相应的XML字符串?

例如:

class Security {
    public $UsernameToken;
    public function __construct()
    {
        $this->UsernameToken = new UsernameToken();
    }
}

class UsernameToken {
    public $Username = 'foo';
    public $Password = 'bar';
};

$soapVar = new \SoapVar(
    new Security(),
    SOAP_ENC_OBJECT
);

从上面的变量$soapVar中,出于测试目的,我想获取以下原始字符串:

<Security>
    <UsernameToken>
        <Username>foo</Username>
        <Password>bar</Password>
    </UsernameToken>
</Security>

0 个答案:

没有答案