The first Parameter of the constructor, the faultcode, of SoapFault must be a string. Otherwise it will lead to an error.
<?php
throw new SoapFault(1, "Error message!"); // wrong
throw new SoapFault("1", "Error message!"); // right
?>(PHP 5, PHP 7, PHP 8)
SoapFault::__construct — SoapFault コンストラクタ
$code,$string,$actor = null,$details = null,$name = null,$headerFault = null
このクラスは、PHP ハンドラから SOAP
フォールトレスポンスを送信した場合に有用です。
faultcode, faultstring,
faultactor および detail
は SOAP フォールトの標準的な要素です。
例1 いくつかの例
<?php
function test($x)
{
return new SoapFault("Server", "Some error message");
}
$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>SOAP フォールトをスローするために PHP の例外機構を使用することができます。
例2 いくつかの例
<?php
function test($x)
{
throw new SoapFault("Server", "Some error message");
}
$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>The first Parameter of the constructor, the faultcode, of SoapFault must be a string. Otherwise it will lead to an error.
<?php
throw new SoapFault(1, "Error message!"); // wrong
throw new SoapFault("1", "Error message!"); // right
?>