array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.is-soap-fault.php', 1 => 'is_soap_fault', ), 'up' => array ( 0 => 'ref.soap.php', 1 => 'SOAP 関数', ), 'prev' => array ( 0 => 'ref.soap.php', 1 => 'SOAP 関数', ), 'next' => array ( 0 => 'function.use-soap-error-handler.php', 1 => 'use_soap_error_handler', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/soap/functions/is-soap-fault.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
is_soap_fault — SOAP コールが失敗したかどうかを調べる
この関数は、SOAP コールが失敗したかどうかを調べたいが、例外を使用したくない
場合に有用です。
この関数を使用するには、オプション exceptions
に
ゼロまたは false
を指定して SoapClient
オブジェクトを作成する必要があります。
この場合、SOAP メソッドは、特別な SoapFault
オブジェクトを返します。
このオブジェクトには、フォルトの詳細 (faultcode,
faultstring, faultactor および faultdetails) が含まれています。
exceptions
が設定されていない場合、
SOAPコールは、エラー時に例外をスローします。
is_soap_fault() は指定したパラメータ
SoapFault オブジェクトであるかどうかを調べます。
object
検査するオブジェクト
例1 is_soap_fault() の例
<?php
$client = new SoapClient("some.wsdl", array('exceptions' => 0));
$result = $client->SomeFunction();
if (is_soap_fault($result)) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}
?>
例2 SOAP の標準的なエラーレポートメソッドは例外となる
<?php
try {
$client = new SoapClient("some.wsdl");
$result = $client->SomeFunction(/* ... */);
} catch (SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
?>