in reply to SOAP::Lite in Windows

I've tried using SOAP::Lite with +trace => qw(all), but the client just prints my debug message "contacting server" and then sits there until the connection actually works. I can't figure out how enable debugging on the server.

you need to do tracing on the server. i prefer using a callback to send tracing info to an existing log:

package My::SOAP::Server; BEGIN { ## configure log here (i like Log::Log4perl) } use SOAP::Lite +trace => [ all => sub{ print $log join( "\n\t" => 'ACK!', @_ ), "\n\n" }, ];

by the way, i find using dispatch_from on your client reduces cross-platform migration errors. i use it now in my clients, and they work on both windows and solaris.

~Particle *accelerates*

Replies are listed 'Best First'.
Re: Re: SOAP::Lite in Windows
by anjiro (Beadle) on Jul 29, 2003 at 01:20 UTC
    Thanks for the hint for logging on the server, but no go. The logging works, however the log gives no information until the client actually connects, a minute and a half later.

    I'm using Tk in my client; I wonder if that might be a problem? I threw together some sample code that breaks just as much as my full code, and it's pretty darn simple:

    The sever:

    #!/usr/bin/perl -w use strict; use SOAP::Transport::HTTP; SOAP::Transport::HTTP::Daemon->new(LocalPort => 3004) ->dispatch_to('My::Soapy')->handle; package My::Soapy; sub testy { return "happy!"; }

    And the client:

    #!/usr/bin/perl -w use strict; use SOAP::Lite; use Tk; my $main = MainWindow->new; my $button = $main->Button(-text => 'go!', -command => \&get); $button->pack; MainLoop; sub get { print "got: " . SOAP::Lite->uri('http://tako:3004/My/Soapy') ->proxy('http://tako:3004')->testy()->result . $/; }

    My only reply on the SOAP::Lite mailing list (thus far) suggests that maybe Windows isn't closing the socket, but I'm not sure how to check on that, or force it to close.

    Daniel Ashbrook

      tk is not the problem. i took your example code and recreated your problem in my win2000 environment. as for creating a good example of the problem, well done! that made this problem easy for me to track down. i wish all my developers could boil their problems down to a examples this small.

      back to the problem at hand. two small changes will fix this right up--one on the server, and one on the client.

      here is my modified client. notice i modified the uri to point to a valid urn. this is very important--the urn is relative to the host, so absolute path really screws it up. in fact, i'm surprised it resolved it at all! there should probably be better error checking for valid urns in SOAP::Lite, to prevent others from making this mistake as well.

      #!/usr/bin/perl -w use strict; use SOAP::Lite; use Tk; my( $server, $port, $urn )= qw(localhost 3004 urn://My/Soapy); my $main= MainWindow->new; my $button= $main->Button( -text => 'go!', -command => \&get, )->pack; MainLoop; sub get { print "got: ", ## SOAP::Lite->uri('http://tako:3004/My/Soapy') SOAP::Lite->uri($urn) ->proxy("http://${server}:$port") ->testy() ->result, $/; }

      okay, i lied. actually the only change you need was to the client. but as i mentioned before, i prefer dispatch_with over dispatch_to, so i've modified your server to use that style. i prefer dispatch_with both because you can set your server up with multiple urns, handled by multiple packages; and because the urn and handler are paired in a hash, they are self-documenting.

      #!/usr/bin/perl -w use strict; use SOAP::Transport::HTTP; my( $server, $port, $urn, $handler )= qw(localhost 3004 urn://My/Soapy My::Soapy); SOAP::Transport::HTTP::Daemon ->new( LocalAddr => $server, LocalPort => 3004, )->dispatch_to('My::Soapy')->handle; ## )->dispatch_with({ $urn => $handler }) ->handle or die 'a horrible death!'; package My::Soapy; sub testy() { 'happy!' }

      by the way, you should always test for errors on your server, even in an example script. and if you are using a perl >= 5.006, you should consider use warnings over -w.

      ~Particle *accelerates*

        Hi Particle,

        Thanks for taking the time to help. Unfortunately, that didn't seem to work. I copy-n'-pasted your code (I'm guessing the #s in the example code are on the wrong line?), and it works perfectly on the Linux box, but on the windows I get a bunch of errors now:

        Tk::Error: 500 Can't read entity body: Unknown error at soapcl2.pl lin +e 19 Carp::croak at D:/Perl/lib/Carp.pm line 191 SOAP::Lite::__ANON__ at D:/Perl/site/lib/SOAP/Lite.pm line 2749 SOAP::Lite::call at D:/Perl/site/lib/SOAP/Lite.pm line 2873 SOAP::Lite::__ANON__ at D:/Perl/site/lib/SOAP/Lite.pm line 2841 main::get at soapcl2.pl line 19 [\&main::get] Tk callback for .button Tk::__ANON__ at D:/Perl/site/lib/Tk.pm line 228 Tk::Button::butUp at D:/Perl/site/lib/Tk/Button.pm line 111 (command bound to event)

        I fiddled around a bit, but I'm not real sure what's causing this.

        Also a question about the urn... I had ->uri('http://tako:3004/My/Soapy') because I'd been cribbing off of the SOAP::Lite Quick Start Guide - the first sample client uses that exact syntax. I'm not at all familiar with SOAP in general, so I'm a little unclear (and the docs don't help much!) on the meanings and usage of stuff like uri, urn and proxy.

        I'm curious - why use warnings rather than -w?

        Thanks a lot!

        Daniel Ashbrook