in reply to Re^3: Perl WSDL WebService Call
in thread Perl WSDL WebService Call

Hi, I tried to add $service->transport->http_request->headers->push_header('Authorization'=>$token); but i get the following error Can't call method "http_request" on an undefined value at C:/Program Files (x86)/NextNine/SiteServer/Perl/ActivePerl-5.14.2.1402/perl/site/lib/SOAP/Li te.pm line 482.

Replies are listed 'Best First'.
Re^5: Perl WSDL WebService Call
by Anonymous Monk on Aug 10, 2014 at 08:45 UTC

    I tried one line of code someplace somewhere

    And then what happened?

    "Works" for me (does everything I expect it to do )

    #!/usr/bin/perl -- ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END if " -otr -opr - +ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; Main( @ARGV ); exit( 0 ); sub Main { my $soap = SOAP::Lite->uri( 'http://127.0.0.1/MyModule' ) ->proxy( 'http://127.0.0.1:1203' ); $soap->transport->add_handler( "request_send", \&pp_dump ); $soap->transport->add_handler( "response_done", \&pp_dump ); my $token = "getValidToken()"; my $service = $soap; $service->transport->http_request->headers->push_header( 'Authorization' => $token ); print "web method : ", $service->getLicenseSummaryInfo(), "\n"; } ## end sub Main sub pp_twig { use XML::Twig; open my( $fh ), '>', \my $str; no warnings 'newline'; XML::Twig->new( qw! pretty_print record ! )->xparse( @_ )->print( +$fh ); return $str; } ## end sub pp_twig sub pp_dump { my $content = $_[0]->content( '' ); $_[0]->content( pp_twig( $content ) ); print $_[0]->as_string, "\n"; return; } ## end sub pp_dump __END__ POST http://127.0.0.1:1203 HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Authorization: getValidToken() User-Agent: SOAP::Lite/Perl/1.11 Content-Length: 441 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://127.0.0.1/MyModule#getLicenseSummaryInfo" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http:/ +/www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSche +ma-instance"> <soap:Body> <getLicenseSummaryInfo xmlns="http://127.0.0.1/MyModule" xsi:nil=" +true"/> </soap:Body> </soap:Envelope>