PHP 8.3.7 Released!

SoapFault::__construct

(PHP 5, PHP 7, PHP 8)

SoapFault::__constructConstrutor SoapFault

Descrição

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

Esta classe é usada para enviar respostas de falha SOAP do manipulador PHP. faultcode, faultstring, faultactor e detail são elementos padrões de uma falha SOAP.

Parâmetros

faultcode

O código de erro do SoapFault.

faultstring

A mensagem de erro do SoapFault.

faultactor

Uma string que identifica o ator que causou o erro.

detail

Mais detalhes sobre a causa do erro.

faultname

Pode ser usado para selecionar a codificação de falha adequada do WSDL.

headerfault

Pode ser usado durante a manipulação do cabeçalho SOAP para relatar um erro no cabeçalho de resposta.

Exemplos

Exemplo #1 Alguns exemplos

<?php
function test($x)
{
return new
SoapFault("Server", "Some error message");
}

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

É possível usar o mecanismo de exceção PHP para lançar uma falha SOAP.

Exemplo #2 Alguns exemplos

<?php
function test($x)
{
throw new
SoapFault("Server", "Some error message");
}

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

Veja Também

add a note

User Contributed Notes 1 note

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