Loading ...
Sorry, an error occurred while loading the content.

Re: [soaplite] Re: How do I add custom trace callbacks?

Expand Messages
  • Lee Carmichael
    Hello Petar, After seeing your example, I just realized that you are trying to debug a server. Sorry my last post won t be much help since it seems that
    Message 1 of 9 , Mar 25 10:37 AM
    • 0 Attachment
      Hello Petar,

      After seeing your example, I just realized that you are trying to debug a server. Sorry my last post won't be much help since it seems that transport level debugging is a client only option.

      It seems that most of the server code doesn't have any trace statements besides the empty create/destroy ones (you can see these as SOAP::Trace::trace( '()' ) ).

      You tell what is traceable by looking through the code for SOAP::Trace::<signal>. For example in SOAP::Lite under the package SOAP::Server you can see an entry like:

          SOAP::Trace::result(@results);

      It seems that you could get information from parameters or results for servers. Which doesn't strike me as terribly helpful.

      I did have an idea that i tested out. Since you said you were trying to debug request and responses, these will get passed to the deserializer and serializer. I was able to write a stub that logs the requests by sub classing the existing deserializer class into one that includes logging.

      Here is an example:

      #!/usr/local/bin/perl5

      use SOAP::Lite +trace => 'all';
      use SOAP::Transport::HTTP;
      use warnings;
      use strict;

      package DebugDS;

      use SOAP::Lite;
      use Data::Dumper qw(Dumper);
      our @ISA =  qw( SOAP::Deserializer ); ## can't use base due to error about deserializer not returning true...

      sub deserialize {
          SOAP::Trace::trace('()');
          my $self = shift;

          SOAP::Trace::trace( $_[0] );

          return $self->SUPER::deserialize( @_ );
      }

      package main;

      my $daemon;
      my $end_port = 9905;
      my $started = 0;

      foreach (my $port = 9900; $port <= $end_port; $port++ ) {
          eval {
              $daemon = SOAP::Transport::HTTP::Daemon
                  -> new( LocalAddr => 'localhost', LocalPort => $port )
                  -> dispatch_to( '../../lib/', 'TestSoap' )
                  -> deserializer( DebugDS->new );
          };

          if (!$@) {
              $started = 1;
              last;
          }
      }

      if (! $started ) { die "ERROR: Failed to start webserver: $@\n"; }

      print "Contact to SOAP server at ", $daemon->url, " ($$)\n";

      $daemon->handle;

      exit;
      ------------------------------------------

      I'm sure you could do something similar to SOAP::Transport::HTTP::Daemon by using a sub class to do custom processing of the accept and dumping out the request/response content. Maybe I'll look at that tonight.

      HTH,

      Lee
    • Petar Shangov
      Hi, thanks to everyone who responded. ... rahed, the problem turned out to be that all the relevant tracing calls are made inside SOAP::Transport::HTTP::Client
      Message 2 of 9 , Mar 25 11:06 AM
      • 0 Attachment
        Hi,

        thanks to everyone who responded.

        ----- Original Message ----
        > From: rahed <raherh@...>
        > To: Petar Shangov <pshangov@...>
        > Cc: soaplite@yahoogroups.com
        > Sent: Tuesday, 24 March, 2009 21:41:48
        > Subject: Re: [soaplite] How do I add custom trace callbacks?
        >
        > Apparently you access your local server. I haven't tried this. When you
        > call a remote host you must get what you want, xml request & response.
        >
        > I guess the trace is not enabled for your particular case or the service
        > is called wrongly.
        >
        > For instance when calling
        >
        > $soap = SOAP::Lite->new(
        > uri => ("http://www.webserviceX.NET"),
        > proxy => ('http://www.webservicex.com/globalweather.asmx' ),
        > );
        >
        > the trace is like this:
        >
        > ...

        rahed,

        the problem turned out to be that all the relevant tracing calls are made inside SOAP::Transport::HTTP::Client and so this code does not work when S::L is used as a server, which is my case.



        ----- Original Message ----
        > From: Peter Farr <Peter.Farr@...>
        > To: Petar Shangov <pshangov@...>
        > Sent: Tuesday, 24 March, 2009 20:43:13
        > Subject: Re: How do I add custom trace callbacks?
        >
        > Peter, I typed this response into the Yahoo group but I haven't seen it
        > show up yet, so here it is again:
        >
        > I can get your daemon to print to a log and to stdout with the following
        > change:
        >
        > use SOAP::Lite +trace => [ all =>
        > sub {
        > open LOGFILE,">>trace.log";
        > print LOGFILE "This:" . $_[0] . "\n";
        > close LOGFILE;
        > warn("This:" . $_[0] . "\n");
        > }
        >
        > ];
        >
        > When I change "all" to "debug" it stops working, but "transport" (or any
        > other valid value) works okay. I suspect a conflict between debug and
        > the SOAP::Transport::HTTP::Daemon code. I don't know what is causing it,
        > but you could always file a bug and see what happens.

        Peter,

        I got this to work, but it still did not print out the request and response strings. The 'debug' option does not work since when used as a server, S::L encounters no calls to SOAP::Trace::debug() during its lifetime. I ended up inserting these calls manually, and submitted a bug report (https://rt.cpan.org/Ticket/Display.html?id=44568).

        > From: Lee Carmichael <lecar_red@...>
        > To: Petar Shangov <pshangov@...>; soaplite@yahoogroups.com
        > Sent: Wednesday, 25 March, 2009 19:37:40
        > Subject: Re: [soaplite] Re: How do I add custom trace callbacks?
        >
        > Hello Petar,
        >
        > After seeing your example, I just realized that you
        are trying to debug a server. Sorry my last post won't be much help
        since it seems that transport level debugging is a client only option.
        >
        > It
        seems that most of the server code doesn't have any trace statements
        besides the empty create/destroy ones (you can see these as
        SOAP::Trace::trace( '()' ) ).
        >
        > You tell what is traceable by
        looking through the code for SOAP::Trace::<signal>. For example
        in SOAP::Lite under the package SOAP::Server you can see an entry like:
        >
        > SOAP::Trace::result(@results);
        >
        > It seems that you could get information from parameters or results for servers. Which doesn't strike me as terribly helpful.
        >
        > I
        did have an idea that i tested out. Since you said you were trying to
        debug request and responses, these will get passed to the deserializer
        and serializer. I was able to write a stub that logs the requests by
        sub classing the existing deserializer class into one that includes
        logging.
        >
        > Here is an example:
        >
        > ...
        >
        > I'm
        sure you could do something similar to SOAP::Transport::HTTP::Daemon by
        using a sub class to do custom processing of the accept and dumping out
        the request/response content. Maybe I'll look at that tonight.

        Lee,

        I received your mail just after I had posted a bug report. Your approach is probably safer in the long run since I am now using a locally modified version of S::L.

        On a side note, I need server debugging since I will be testing my server with various non-perl clients, and it is easier to do my testing on the perl side.


        Regards,

        Petar
      Your message has been successfully submitted and would be delivered to recipients shortly.