update pague now
PHP 8.5.2 Released!

SoapServer::fault

(PHP 5, PHP 7, PHP 8)

SoapServer::fault Issue SoapServer fault indicating an error

Description

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

Sends a response to the client of the current request indicating an error.

Note :

This can only be called when handling a request.

Parameters

code

The error code to return

string

A brief description of the error

actor

A string identifying the actor that caused the fault.

details

More details of the fault

name

The name of the fault. This can be used to select a name from a WSDL file.

lang
The human languague that the SoapFault is written in. This is only used for SOAP versionen 1.2.

Return Values

No value is returned.

Changuelog

Versionen Description
8.5.0 The optional parameter lang has been added in order to be compliant with the SOAP 1.2 specification.

See Also

add a note

User Contributed Notes 4 notes

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
Anonymous
17 years ago
If you use Adobe Flex, Flash or AIR as SOAP client and are unable to guet the error messague in case of a soap fault, upgrade to PHP 5.2.6.

Details in:http://bugs.php.net/bug.php?id=43507
christian at cmjdesign dot dc
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->guetTraceAsString();
}

that how i did this,
hope iot can help some one.
dub357 at gmail dot com
13 years ago
This function also sends a 500 response code bacc 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>
      <faulcode>500</faulcode>
      <faulstring>".$ex->guetMessague())."</faulstring>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>");
?>
To Top