Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 994161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:32:09+00:00 2026-05-16T06:32:09+00:00

I try to log all soap calls, with subrutine called and arguments passed to

  • 0

I try to log all soap calls, with subrutine called and arguments passed to the subroutine, my solution was this:

#!/usr/bin/perl -w
use SOAP::Transport::HTTP;

SOAP::Transport::HTTP::CGI   
    -> dispatch_to('SoapStatus')
    -> handle;

package SoapStatus;

use POSIX qw(strftime);

# Can I capture arguments and called sub from here ?
#&myLog(@_);

sub myLog
{
    my $now_string = POSIX::strftime "%Y-%m-%d %H:%M:%S", localtime;
    open(my $tmp_file, ">>", "/tmp/soap.log") or die "Can not open log file: $!\n";
    print $tmp_file $now_string.' '.$ENV{'REMOTE_USER'}.' '.$ENV{'REMOTE_ADDR'}.' '.(caller(1))[3].'('.(join(', ', @_)).')'."\n";
    close($tmp_file) or die "Can not close file: $!\n";
    return 0;
}

sub test
{
    myLog(@_);
    ...
    return @something;
}

My question is, there is a way of capturing arguments from inside the package block, but outside the sub, so I do not need to call myLog from every sub ?

EDIT:
This is the script where the call is made ( the script is on another server )

#!/usr/bin/perl -w
use SOAP::Lite;
use Data::Dumper;
$user='myUser';
$pass='myPass';

@soap = SOAP::Lite
  -> uri('https://example.com/SoapStatus')
  -> proxy('https://'.$user.':'.$pass.'@example.com/cgi-bin/soap/soap.cgi')
  -> test('var1', 'var2')
  -> result;
print Dumper \@soap;

The log file looks like this:

2010-08-16 17:38:33 myUser 10.10.10.1 SoapStatus::test(SoapStatus, var1, var2)
2010-08-16 17:38:47 myUser 10.10.10.1 SoapStatus::test(SoapStatus, var1, var2)

using SOAP trace in the server script:

#!/usr/bin/perl -w
use SOAP::Transport::HTTP;
use POSIX qw(strftime);

SOAP::Transport::HTTP::CGI   
    -> dispatch_to('SoapStatus')
    -> handle;
use SOAP::Lite +trace => [ method, parameters => \&myLog ];

sub myLog
{
    my $now_string = POSIX::strftime "%Y-%m-%d %H:%M:%S", localtime;
    open(my $tmp_file, ">>", "/tmp/soap.log") or die "Can not open log file: $!\n";
    print $tmp_file $now_string.' '.$ENV{'REMOTE_USER'}.' '.$ENV{'REMOTE_ADDR'}.' '.(join(', ', @_)).')'."\n";
    close($tmp_file) or die "Can not close file: $!\n";
    return 0;
}

package SoapStatus;

sub test
{
    myLog(@_);
    ...
    return @something;
}

I get 2 rows in the log file:

2010-08-16 17:19:56 radu.maris 193.231.238.8 var1,var2
2010-08-16 17:19:56 radu.maris 193.231.238.8 testResponse,response1,response2

response1 and response 2 are part of @something returned by the test sub.

How can I make it print something like the pervious log example, I mean force it to print method and parameters on the same line, and how to get rid of “Response” word that is sticked to the name of the sub called ?, I cant find anithing in the documentation ( still searching … )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:32:10+00:00Added an answer on May 16, 2026 at 6:32 am

    Your code is confusing. When is the SOAP call supposed to be made? When is the call supposed to be logged?

    You can create a wrapper around your SOAP calls:

    sub log_and_dispatch {
        log_soap( @_ );
        dispatch_soap( @_ );
    }
    

    However, on closer examination, it looks like Soap::Trace might be what you are looking for.

    Alternatively, you could use Hook::LexWrap or Sub::Override to write wrappers for all routines you want to log. I suspect Hook::LexWrap would be more suitable for what you are trying to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code first: AssetManager mgr = DeviceListActivity.this.getApplicationContext().getAssets(); try { Log.e(Glenn:, address); FileOutputStream fout = mgr.openFd(device/device_address.txt).createOutputStream();
I followed this tutorial . But whenever I try to log in with my
This is my thread: public void run() { Log.d(ConnectionThread,Starting Server Connection); try { while(isThereActivityRunning())
this is my thread: @Override public void run() { Log.d(ConnectionThread,Starting Server Connection); try {
With subversion when i commit (with log message) all works well and when try
I'm getting following error when I try to log onto phpMyAdmin. User * *
try { // Code } catch (Exception ex) { Logger.Log(Message, ex); throw; } In
I had try to implement the send me log feature into my apps but
I try to build libtorrent(rasterbar- libtorrent). It cannot be build. the build log is
$(item).droppable({ drop: function(event, ui) { console.log(triggered); } }); I try to call drop by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.