1# ======================================================================
2#
3# Copyright (C) 2000-2003 Paul Kulchenko (paulclinger@yahoo.com)
4# SOAP::Lite is free software; you can redistribute it
5# and/or modify it under the same terms as Perl itself.
6#
7# $Id: Fault.pm,v 1.1 2004/10/12 18:47:55 byrnereese Exp $
8#
9# ======================================================================
10
11=pod
12
13=head1 NAME
14
15SOAP::Fault - encapsulates SOAP faults prior to their serialization or after their deserialization
16
17=head1 DESCRIPTION
18
19This class encapsulates SOAP faults prior to their serialization or after their deserialization. The methods available are a constructor and four accessors. Each accessor creates an object on demand, just as the other classes do, when called as a static method. Like other accessors in the SOAP::Lite package, they return the object itself when setting the attribute.
20
21=head1 GENERATING A SOAP FAULT
22
23To generate a SOAP Fault simply issue a Perl die command on the server side as you might normally. The SOAP processor will intercept the die command and return a SOAP Fault, using the string passed to the die command as the faultstring, to the client making the call. If you require having more control over the SOAP Fault returned to the client, then simply pass a SOAP::Fault object to the die command and the SOAP processor will behave accordingly. For example:
24
25  die SOAP::Fault->faultcode('Server.Custom') # will be qualified
26                 ->faultstring('Died in server method')
27                 ->faultdetail(bless {code => 1} => 'BadError')
28                 ->faultactor('http://www.soaplite.com/custom');
29
30=head1 METHODS
31
32=over
33
34=item new(optional data)
35
36    $fault = SOAP::Fault->new(faultcode => 'Server');
37
38Explicitly creates a new SOAP::Fault object. Any of the four attributes represented next by accessor methods may be passed in the argument list with values immediately following their attribute name.
39
40=item faultcode(optional value)
41
42    $fault->faultcode('MethodUnknown');
43
44Returns the current fault code or sets it if a value is given.
45
46=item faultstring(optional value)
47
48    $fault->faultstring("There is no $method here");
49
50Returns or sets the fault string.
51
52=item faultactor(optional value)
53
54    $fault->faultcode($header->actor);
55
56Returns or sets the fault-actor element. Note that the actor isn't always required in a SOAP fault.
57
58=item faultdetail(optional value)
59
60    $fault->faultcode(bless { proxy => $ip }, 'Err');
61
62Returns or sets the fault's detail element. Like the actor, this isn't always a required element. Note that fault detail content in a message is represented as tag blocks. Thus, the values passed to this accessor when setting the value are either SOAP::Data objects, or more general blessed hash references.
63
64=back
65
66In addition to these methods, the SOAP::Fault package also provides detail as an alias for faultdetail. The former is the actual name of the element with SOAP faults, but the latter name is less ambiguous when regarded with the rest of the SOAP::Lite package. Objects of this class also have a special stringification enabled. If an object is printed or otherwise stringified, the value produced is faultcode: faultstring, with the attribute values of the object.
67
68=head1 SEE ALSO
69
70L<SOAP::Data>, L<SOAP::Header>, L<SOAP::SOM>
71
72=head1 ACKNOWLEDGEMENTS
73
74Special thanks to O'Reilly publishing which has graciously allowed SOAP::Lite to republish and redistribute large excerpts from I<Programming Web Services with Perl>, mainly the SOAP::Lite reference found in Appendix B.
75
76=head1 COPYRIGHT
77
78Copyright (C) 2000-2004 Paul Kulchenko. All rights reserved.
79
80This library is free software; you can redistribute it and/or modify
81it under the same terms as Perl itself.
82
83=head1 AUTHORS
84
85Paul Kulchenko (paulclinger@yahoo.com)
86
87Randy J. Ray (rjray@blackperl.com)
88
89Byrne Reese (byrne@majordojo.com)
90
91=cut
92