php-doc-en/reference/soap/functions/is-soap-fault.xml
2004-11-08 12:10:21 +00:00

89 lines
2.6 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.7 $ -->
<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 failed, but don't like to use exceptions.
To use it you must create a SoapClient object with
<literal>exceptions</literal> option set to zero or &false;.
In this case, the SOAP method will return a special SoapFault
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 SoapFault object.
</para>
<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_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_ERROR);
}
?>
]]>
</programlisting>
</example>
</para>
<para>
See also
<function>SoapClient::SoapClient</function>, and
<function>SoapFault::SoapFault</function>.
</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
-->