PHP 8.5.4 Released!

SoapServer::fault

(PHP 5, PHP 7, PHP 8)

SoapServer::faultエラーを示す SoapServer フォールト を発行する

説明

public SoapServer::fault(
    string $code,
    string $string,
    string $actor = "",
    mixed $details = null,
    string $name = "",
    string $lang = ""
): void

現在のリクエストに対するレスポンスとして、エラーを表す内容をクライアントに送信します。

注意:

これは、リクエストを処理する際にのみコールされます。

パラメータ

code

返したいエラーコード。

string

エラーについての簡単な説明。

actor

フォールトを引き起こしたアクターをあらわす文字列。

details

フォールトについての詳細。

name

フォールトの名前。これは WSDL ファイルにある名前を使うことができます。

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

戻り値

値を返しません。

変更履歴

バージョン 説明
8.5.0 SOAP 1.2 仕様に準拠するため、 オプションのパラメータ lang が追加されました。

参考

add a note

User Contributed Notes 4 notes

up
3
Amr Mostafa
16 years ago
This function currently terminates execution as well, which may be undesirable. See: http://bugs.php.net/bug.php?id=49513
up
0
Anonymous
17 years ago
If you use Adobe Flex, Flash or AIR as SOAP client and are unable to get the error message in case of a soap fault, upgrade to PHP 5.2.6.

Details in:
http://bugs.php.net/bug.php?id=43507
up
-3
christian at cmjdesign dot dk
12 years ago
hi,
to control the fault output one may do the following

/**
 * mySoapServer class
 */
class mySoapServer extends SoapServer {
    public function __construct($wsdl, array $options = null) {
        parent::SoapServer($wsdl, $options);
    }
    public function fault ($code, $string, $actor = null, $details = null, $name = null) {
        throw new SoapFault($code, $string, $actor, $details, $name);
    }
}

Use:
try {
    $server = new mySoapServer(null, array('uri' => $_SERVER['REQUEST_URI']));
    $server->setClass('mySoapAPI');
    $server->handle();
} catch (SoapFault $exc) {
    echo $exc->getTraceAsString();
}

that how i did this,
hope iot can help some one.
up
-5
dub357 at gmail dot com
14 years ago
This function also sends a 500 response code back to the client with the request.
This was causing issues with an Apache Axis 1.2 client I had so I instead implemented by own fault handling:

<?php
header("Content-Type: text/xml");
header("Status: 200");
die("<SOAP-ENV:Envelope xmlns:SOAP-ENV=\\"http://schemas.xmlsoap.org/soap/envelope/\\">
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
      <faultcode>500</faultcode>
      <faultstring>".$ex->getMessage())."</faultstring>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>");
?>
To Top