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,$lang = ""
このクラスは、PHP ハンドラから SOAP
フォールトレスポンスを送信した場合に有用です。
code, string,
actor および details
は SOAP フォールトの標準的な要素です。
| バージョン | 説明 |
|---|---|
| 8.5.0 |
SOAP 1.2 仕様に準拠するため、オプションのパラメータ
lang が追加されました。
|
例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
?>