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

Does anyone know how can i send the oauth token with SOAP::Lite -> service I think i need to add it to the Authorization Header but i cant figure out how to do it

First you need to know where it needs to go, then just get it there, ->transport is the LWP object you want

Replies are listed 'Best First'.
Re^4: Perl WSDL WebService Call
by Anonymous Monk on Aug 10, 2014 at 07:06 UTC
    Hi , Thanks for your quick reply :-) my current Code: my $token = getValidToken(); my $url = "https://sepm-site:8446/sepm/ws/v1/LicenseService?wsdl"; my $service = SOAP::Lite->service($url); print "web method : ", $service->getLicenseSummaryInfo(), "\n"; how can i add the Oauth token to the service Object? / or how can i add it to the header
Re^4: Perl WSDL WebService Call
by Anonymous Monk on Aug 10, 2014 at 08:05 UTC
    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.

      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>
Re^4: Perl WSDL WebService Call
by Anonymous Monk on Aug 10, 2014 at 09:03 UTC
    Hi thanks again for your help i am not sure how can i replace my $url = "https://sepm-site:8446/sepm/ws/v1/LicenseService?wsdl"; #my $service = soap->service($url); with my $soap = SOAP::Lite->uri( 'http://127.0.0.1/MyModule' ) ->proxy( 'http://127.0.0.1:1203' ); What will be my uri and what is the proxy

      ...

      Demo is demo, its for demonstration purposes, however you setup $soap, set it up