Rice has asked for the wisdom of the Perl Monks concerning the following question:

I am sending requests to a web service using SOAP::Lite, but the service is returning an error code. I think I have set up my request correctly, but have yet to figure out how to print out the XML I am sending to verify that it is being sent as specified by the operator of the service. I can view the response XML by setting outputxml to true as follows:
my $uri = "http://service/uri" ; my $proxy = "https://service.provider.address/Service/service.asmx?WSD +L" ; my $service = SOAP::Lite ->uri($uri) ->proxy($proxy) ->autotype(0) ->outputxml(1) ->on_action( sub { join '/', @_ } ) ; my $response = $service->MethodName( SOAP::Header ->name( 'AuthHeader' ) ->value( { header1 => $header_1, header2 => $header_2 } ), SOAP::Data ->name( 'NamedParam1' ) ->type( 'string' ) ->value( $named_param_1 ), SOAP::Data ->name( 'NamedParam2' ) ->type( 'string' ) ->value( $named_param_2 ) ) ; print "RESPONSE: $response\n" ;
Is there some way I can see the request in a similar fashion?

Replies are listed 'Best First'.
Re: Displaying SOAP::Lite request XML
by jhourcle (Prior) on Mar 29, 2006 at 16:11 UTC
      Ok, so it was a simple matter of adding the following code to the use SOAP::Lite statement.
      use SOAP::Lite +trace => [ transport => sub { print $_[0]->as_string } ];
      Not quite as flexible as I was hoping, but it does the job. Thanks for pointing me in the right direction.
Re: Displaying SOAP::Lite request XML
by samtregar (Abbot) on Mar 29, 2006 at 18:10 UTC
    If you need to see just the XML then the debug options in SOAP::Lite should do it. If you also need to see the HTTP headers then you may need to resort to sniffing packets with something like ethereal. If you've never used a packet sniffer before the learning curve can be steep, but it's time well spent. There's nothing quite like seeing exactly what's happening!

    -sam