in reply to SOAP::Lite and sessions?

What's probably happening is that the service is coded crappily and is not handling this error gracefully. Did you try using a cookie_jar? I had a lot of problems getting that to work when I tried it, so I'll put this example (_handle_fault is from bric_soap in Bricolage, in case Sam Tregar reads this :) ):

#!/usr/bin/perl use strict; use warnings; use SOAP::Lite trace => [qw(debug)], on_fault => \&_handle_fault; import SOAP::Data 'name'; use HTTP::Cookies; my $COOKIE_FILE = '/tmp/bs-wsdl-cookies.txt'; my $WSDL_FILE = 'file:///tmp/bricolage-simpletest.wsdl'; main(); exit; sub main { my $client = SOAP::Lite->service($WSDL_FILE); # xxx: I have no idea what magic is done # to initialize things (transport), # so I end up calling login a 2nd time just to add the cookie_jar! # $client->login(name(username => 'admin'), # name(password => 'change me now!')); $client->login('admin', 'change me now!'); my $cookie_jar = HTTP::Cookies->new(ignore_discard => 1, file => $COOKIE_FILE, autosave=>1); $client->transport->cookie_jar($cookie_jar); # xxx: 2nd login # $client->login(name(username => 'admin'), # name(password => 'change me now!')), $/; $client->login('admin', 'change me now!'); # .... } # handle faults from SOAP::Lite's on_fault event sub _handle_fault { my ($soap, $r) = @_; # print out the error as appropriate if (ref $r) { if ($r->faultstring eq 'Application error' and ref $r->faultdetail and ref $r->faultdetail eq 'HASH' ) + { # this is a bric exception, the interesting stuff is in de +tail print STDERR "Call failed:\n\n", join("\n", values %{$r->faultdetail}), $/, $/; } else { print STDERR "Call failed:\n\n", $r->faultstring, $/, $/; } print STDERR "Check the Apache error log for more detail.\n"; } else { print STDERR "TRANSPORT ERROR: ", $soap->transport->status, "\ +n"; print STDERR "Check the Apache error log for more information. +\n"; } return SOAP::SOM->new(); }

I think that worked for me at least. Also, if you figure out how to only have to login once, I'd appreciate knowing how!

Maybe you should write it in Java.... I was complaining about WSDL support in Perl (generally Perl in the "enterprise") just the other day.

Replies are listed 'Best First'.
Re^2: SOAP::Lite and sessions?
by tilly (Archbishop) on Jul 23, 2007 at 17:27 UTC
    I had not tried the cookie jar idea.

    I'd already settled on writing it in Java. At this point I know I can hit my deadline writing it in Java, and Perl is a question mark, so I'll stick with Java. When I'm done I'll have other things to do, so I doubt I'll revisit this project.

Re^2: SOAP::Lite and sessions?
by Anonymous Monk on Apr 18, 2008 at 15:34 UTC
    Just a tip. If you do this, you won't have to call login 2x:
    use SOAP::Lite; use HTTP:: Cookies; my $COOKIE = './coooooooooookie.txt'; my $SET_COOKIE = HTTP::Cookies->new(ignore_discard => 1, file=> $COOKIE, autosave=>1); my $soapLite = SOAP::Lite->new(); $soapLite->proxy($end_point, cookie_jar => $SET_COOKIE); $soapLite->uri($uri_slash_method); ...
    I've had success putting that (plus other pertinent info) into a _call method, then constructing separate methods that are called through _call. Hope that helps.
      Sorry, wasn't logged in. If anybody has any questions, that was my post above...
Re^2: SOAP::Lite and sessions?
by erroneousBollock (Curate) on Jul 19, 2007 at 23:17 UTC
    Tried SOAP::WSDL ?

    It handles complex types, seems to properly map to client side objects if you supply appropriately named classes, handles caching, and is a sub-class of SOAP::Lite for clients.

    -David

      I tried it, and it was worse for my needs. I couldn't even generate evidence that the login method did anything!
      I didn't try it yet, but I did ask the author to update the CHANGES file a couple weeks ago after noticing that it was being updated recently. :) He replied that 2.0 is a rewrite, though should have mostly the same API.