php-doc-en/reference/soap/functions/is-soap-fault.xml
Hannes Magnusson c030e2adf7 Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@238160 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-20 22:25:43 +00:00

117 lines
3.2 KiB
XML

<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.10 $ -->
<refentry xml:id="function.is-soap-fault" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>is_soap_fault</refname>
<refpurpose>
Checks if SOAP call was failed
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<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
<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>obj</parameter></term>
<listitem>
<para>
The tested object.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</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><xref linkend="function.soap-soapclient-construct" /></member>
<member><xref linkend="function.soap-soapfault-construct" /></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:"../../../../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
-->