CakeFest 2024: The Official CakePHP Conference

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
)

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

パラメータ

faultcode

SoapFault のエラーコード

faultstring

SoapFault のエラーメッセージ

faultactor

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

detail

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

faultname

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

headerfault

レスポンスヘッダにおいて 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();
?>

参考

add a note

User Contributed Notes 1 note

up
3
csnaitsirch at web dot de
13 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