PHP 8.5.0 Alpha 1 available for testing

SoapFault::__construct

(PHP 5, PHP 7, PHP 8)

SoapFault::__constructConstructor de SoapFault

Descripción

public SoapFault::__construct(
    array|string|null $code,
    string $string,
    ?string $actor = null,
    mixed $details = null,
    ?string $name = null,
    mixed $headerFault = null
)

SoapFault sirve para enviar errores SOAP desde PHP.faultcode, faultstring, faultactor y detail son los elementos estándar SOAP.

Parámetros

faultcode

El código de error de SoapFault.

faultstring

El mensaje de error de SoapFault.

faultactor

Una cadena que identifica al actor que causó el error.

detail

faultname

Puede ser utilizado para seleccionar la codificación adecuada desde WSDL.

headerfault

Puede ser utilizado durante la gestión del encabezado SOAP para reportar un error en el encabezado de respuesta.

Ejemplos

Ejemplo #1 Algunos ejemplos con SoapFault

<?php
function test($x)
{
return new
SoapFault("Server", "Un mensaje de error");
}

$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>

Es posible utilizar el mecanismo de excepciones de PHP para lanzar excepciones SoapFault.

Ejemplo #2 Emisión de excepciones SoapFault

<?php
function test($x)
{
throw new
SoapFault("Server", "Un mensaje de error");
}

$server = new SoapServer(null, array('uri' => "http://test-uri/"));
$server->addFunction("test");
$server->handle();
?>

Ver también

add a note

User Contributed Notes 1 note

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