php-doc-en/reference/soap/functions/is-soap-fault.xml
Côme Chilliet e64ea89bbe Remove PHP4 constructors from ext/soap documentation
Contructors were still documented as aliases to classname::classname
 with the real documentation in classname::classname.

Closes GH-332.
2021-01-22 14:26:20 +01:00

123 lines
3.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.is-soap-fault" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>is_soap_fault</refname>
<refpurpose>Checks if a SOAP call has failed</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>is_soap_fault</methodname>
<methodparam><type>mixed</type><parameter>object</parameter></methodparam>
</methodsynopsis>
<para>
This function is useful to check if the SOAP call failed, but
without using exceptions. To use it, create a
<classname>SoapClient</classname> object with the <literal>exceptions</literal>
option set to zero or &false;.
In this case, the SOAP method will return a special
<classname>SoapFault</classname> object which encapsulates the fault
details (faultcode, faultstring, faultactor and faultdetails).
</para>
<para>
If <literal>exceptions</literal> is not set then SOAP call will throw
an exception on error.
<function>is_soap_fault</function> checks if the given
parameter is a <classname>SoapFault</classname> object.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>object</parameter></term>
<listitem>
<para>
The object to test.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<!-- See also &return.success; -->
<para>
This will return &true; on error, and &false; otherwise.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>is_soap_fault</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$client = new SoapClient("some.wsdl", array('exceptions' => 0));
$result = $client->SomeFunction();
if (is_soap_fault($result)) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
<example>
<title>SOAP's standard method for error reporting is exceptions</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$client = new SoapClient("some.wsdl");
$result = $client->SomeFunction(/* ... */);
} catch (SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SoapClient::__construct</methodname></member>
<member><methodname>SoapFault::__construct</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->