PHP 8.5.4 Released!

SoapFault::__construct

(PHP 5, PHP 7, PHP 8)

SoapFault::__constructSoapFault コンストラクタ

説明

public SoapFault::__construct(
    array|string|null $code,
    string $string,
    ?string $actor = null,
    mixed $details = null,
    ?string $name = null,
    mixed $headerFault = null,
    string $lang = ""
)

このクラスは、PHP ハンドラから SOAP フォールトレスポンスを送信した場合に有用です。 code, string, actor および details は SOAP フォールトの標準的な要素です。

パラメータ

code

SoapFault のエラーコード

string

SoapFault のエラーメッセージ

actor

エラーの原因となったアクターを識別する文字列

details

エラーの原因についての詳細な情報

name

WSDL からの厳密なフォールトエンコーディングを取得するために利用可能

headerFault

レスポンスヘッダにおいて SOAP ハンドラがエラーの報告処理を行っている間に利用可能

lang
SoapFault が記述されている自然言語。SOAP バージョン 1.2 でのみ使用されます。

変更履歴

バージョン 説明
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();
?>

参考

add a note

User Contributed Notes 1 note

up
2
csnaitsirch at web dot de
15 years ago
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
?>
To Top