php-doc-en/reference/soap/functions/is-soap-fault.xml

86 lines
2.4 KiB
XML
Raw Normal View History

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.is-soap-fault">
<refnamediv>
<refname>is_soap_fault</refname>
<refpurpose>
checks if SOAP call was failed
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>bool</type><methodname>is_soap_fault</methodname>
<methodparam><type>mixed</type><parameter>obj</parameter></methodparam>
</methodsynopsis>
<para>
This function is useful when you like to check if the
SOAP call was failed, but don't like to use exceptions.
To use it you must create a SoapClient object with
exceptions option set to zero or &false;.
In this case SOAP method will return a special SoapFault
object which encapsulate the fault details (faultcode,
faultstring, faultactor and faultdetails).
</para>
<para>
If exceptions is not set then SOAP call will throw an
exception on error.
<function>is_soap_fault</function> checks if the given
parameter is a SoapFault object.
</para>
<para>
<example>
<title><function>is_soap_fault</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$client = SoapClient("some.wsdl", array('exceptions' => 0));
$result = $client->SomeFunction(...);
if (is_soap_fault($result)) {
trigger_error("SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faulstring})", E_ERROR);
}
?>
]]>
</programlisting>
</example>
<example>
<title>SOAP's standard method for error reporting is exceptions</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$client = SoapClient("some.wsdl");
$result = $client->SomeFunction(...);
} catch (SoapFault $fault) {
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faulstring})", E_ERROR);
}
?>
]]>
</programlisting>
</example>
</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:"../../../../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
-->