SOAP::Trace(3)
π SOAP::Trace(3) β the vibes guide β¨
okay so this page is from the Perl world β specifically SOAP::Trace in the user-contributed Perl docs section, and bestie, it's a short one but it slaps. Let's get into it π«Ά
β¨ NAME β¨
SOAP::Trace β used only to manage and manipulate the runtime tracing of execution within the toolkit. That's it. That's the whole job. No cap.
π DESCRIPTION π
Lowkey the most important thing to know: this class has no methods or objects. None. Zero. It exists purely to manage and manipulate the runtime tracing of execution within the toolkit. Periodt.
And since there are no methods to talk about, this section is instead gonna review the events you can configure and the ways of configuring them. Cute, right? π
π¦ SYNOPSIS π¦
So tracing gets enabled by the SOAP::Lite import method. Usually that happens at compile-time, but you can do it explicitly by calling import directly β you're the main character, you make the rules π
The commands for setting up tracing all start with the keyword +trace. Alternately, +debug works too β the two are interchangeable, iykyk.
After that initial keyword, you list one or more of the signals detailed below, optionally with a callback to handle them. And here's the slay part: when you want multiple signals handled by a single callback, you just list all of them first, then the callback at the end, like this:
use SOAP::Lite +trace =>
method => fault => \&message_level,
trace => objects => \&lower_level;
In that little fragment, the reference to message_level gets installed as the callback for both the method and fault signals, while lower_level is installed for the trace and object events. Two-for-one deal, we love to see it π
If you don't explicitly provide callbacks, the default tracing action is to log a message to Perl's STDOUT file descriptor. And heads up β callbacks should expect one or more arguments passed in, though the nature of those arguments varies based on the signal. Just trust the process β¨
Any signal can be disabled by prefacing the name with a hyphen, like -result. This is extra useful with the pseudosignal "all," which is shorthand for the full list of signals. So this fragment right here disables only the two signals while still enabling everything else:
SOAP::Lite->import(+trace => all => -result => -parameters);
And if you use the keyword +trace (or +debug) with no signals specified at all? It enables all signals, as if all were implied. Sneaky but iconic π
The signals and what they mean follow below β each one also has a lil note about whether it's relevant to a server application, a client application, or both.
π₯ TRACE SIGNALS π₯
transportβ Client only β Triggered in the transport layer just before a request is sent and immediately after a response is received. Every time the signal fires, the sole argument to the callback is the relevant object. On requests that's anHTTP::Requestobject; for responses it's anHTTP::Responseobject. Obsessed with the precision here πdispatchβ Server only β Triggered with the full name of the method being dispatched, just before execution is passed to it. Ngl though β it is currently disabled inSOAP::Lite 0.55. Sad, I know πresultβ Server only β Triggered after the method has been dispatched and it's passed the results returned from the method as a list. Key detail: the result values have not yet been serialized when this signal is sent πparametersβ Server only β Triggered before a method call is actually dispatched, with the data that's intended for the call itself. The parameters for the method call get passed in as a list, after having been deserialized into Perl data πΈheadersβ Server only β This signal should be for triggering on the headers of an incoming message, but bestie it just isn't implemented as ofSOAP::Lite 0.55. It's giving aspiration π«objectsβ Client or server β Highlights when an object is instantiated or destroyed. Triggered in thenewandDESTROYmethods of the variousSOAP::Liteclasses β¨methodβ Client or server β Triggered with the list of arguments whenever the envelope method ofSOAP::Serializeris invoked with an initial argument ofmethod. Little detail: the initial string itself isn't passed to the callback πfaultβ Client or server β Same deal as themethodsignal earlier, except this one triggers whenSOAP::Serializer::envelopeis called with an initial argument offaultπ₯freeformβ Client or server β Like the two previous, this signal triggers when the methodSOAP::Serializer::envelopeis called with an initial parameter offreeform. This syntax is used when the method is creatingSOAP::Dataobjects from free-form input data π¦traceβ Client or server β Triggered at the entry-point of many of the more-significant functions. Not all the functions within theSOAP::Liteclasses trigger this signal, though β the ones that do are primarily the highly visible functions described in the interface descriptions for the various classes πdebugβ Client or server β Used in the various transport modules to track the contents of requests and responses (as ordinary strings, not as objects) at different points along the way β
π§ EXAMPLES π§
πΈ SELECTING SIGNALS TO TRACE
This code snippet enables tracing for all signals:
use SOAP::Lite +trace => 'all';
You can disable tracing for a set of signals by prefixing the signal name with a hyphen. So if you want tracing for every signal EXCEPT transport signals, you'd use this:
use SOAP::Lite +trace => [ qw(all -transport) ];
π LOGGING SIGNALS TO A FILE
You can optionally provide a subroutine or callback to each signal trace you declare. Each time a signal is received, it gets passed to the corresponding subroutine. For example, this code effectively logs all fault signals to a file called fault.log:
use SOAP::Lite +trace => [ fault => \&log_faults ];
sub log_faults {
open LOGFILE,">fault.log";
print LOGFILE, $_[0] . "\n";
close LOGFILE;
}
And you can also use a single callback for multiple signals using this:
use SOAP::Lite +trace => [ method, fault => \&log ];
π LOGGING MESSAGE CONTENTS
Okay the transport signal is unique because it is not a text string β it's the actual HTTP::Request being sent (just prior to being sent), or the HTTP::Response object (immediately after it was received). Here's how to make use of that:
use SOAP::Lite +trace => [ transport => \&log_message ];
sub log_message {
my ($in) = @_;
if (class($in) eq "HTTP::Request") {
# do something...
print $in->contents; # ...for example
} elsif (class($in) eq "HTTP::Response") {
# do something
}
}
π ON_DEBUG
The "on_debug" method is available too, as in:
use SOAP::Lite;
my $client = SOAP::Lite
->uri($NS)
->proxy($HOST)
->on_debug( sub { print @_; } );
π ACKNOWLEDGEMENTS π
Special thanks to O'Reilly publishing, which has graciously allowed SOAP::Lite to republish and redistribute large excerpts from Programming Web Services with Perl β mainly the SOAP::Lite reference found in Appendix B. Genuinely so generous of them π«Ά
π COPYRIGHT π
Copyright (C) 2000-2004 Paul Kulchenko. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. fr fr.
π AUTHORS π
- Paul Kulchenko (
paulclinger@yahoo.com) π - Randy J. Ray (
rjray@blackperl.com) β¨ - Byrne Reese (
byrne@majordojo.com) π¦
and that's the whole page, bestie β brought to you by perl v5.42.0, dated 2024-03-04, in the classic SOAP::Trace(3) manpage slot. go trace responsibly π
π
π¦ where this page comes from
- opensuse-leap 16.0: perl-SOAP-Lite 1.27-bp160.1.11 Β· (Artistic-1.0 OR GPL-1.0-or-later) AND CC-BY-ND-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms