我需要调试一些使用肥皂客户端的代码。我在 php.net 中找到了 getLast* 方法,但是当我尝试获取最后一个调试请求时,它返回 NULL
<?php
$client = new SoapClient("http://www.webservicex.net/ConverPower.asmx?WSDL");
$response = $client->ChangePowerUnit(array(
"PowerValue" => 100,
"fromPowerUnit" => "horsepower",
"toPowerUnit" => "megawatts"
));
echo "====== REQUEST HEADERS =====" . PHP_EOL;
var_dump($client->__getLastRequestHeaders());
echo "========= REQUEST ==========" . PHP_EOL;
var_dump($client->__getLastRequest());
echo "========= RESPONSE =========" . PHP_EOL;
var_dump($response);
?>
代码执行结果:
$php soap_test.php
====== REQUEST HEADERS =====
NULL
========= REQUEST ==========
NULL
========= RESPONSE =========
object(stdClass)#2 (1) {
["ChangePowerUnitResult"]=>
float(0.0746)
}
如何获取最后一个 SoapClient 请求的正文和标头的内容?