SoapServer::fault

(PHP 5, PHP 7, PHP 8)

SoapServer::fault β€” Π‘ΠΎΠΎΠ±Ρ‰Π°Π΅Ρ‚ ΠΎ сбоС SOAP-сСрвСра ΠΈΠ·-Π·Π° ошибки

ОписаниС

public function 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 Π’ ΠΌΠ΅Ρ‚ΠΎΠ΄ Π΄ΠΎΠ±Π°Π²ΠΈΠ»ΠΈ Π½Π΅ΠΎΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹ΠΉ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ lang, Ρ‡Ρ‚ΠΎΠ±Ρ‹ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ ошибки соотвСтствовал спСцификации ΠΏΡ€ΠΎΡ‚ΠΎΠΊΠΎΠ»Π° SOAP 1.2.

Π‘ΠΌΠΎΡ‚Ρ€ΠΈΡ‚Π΅ Ρ‚Π°ΠΊΠΆΠ΅

  • SoapFault::__construct() - Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅Ρ‚ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ SoapFault
οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 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 ΒΆ
13 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>");
?>