Saturday, 15 September 2012

Perl SOAP::LITE -- can't authenticate? -



Perl SOAP::LITE -- can't authenticate? -

i'm trying -- , failing -- write simple test app using soap::lite access hp service manager site. (i've tried soap::wsdl, farther reading made me believe isn't required want do.)

i'm new soap, new these packages, , new i'm trying do, don't know how many things i'm doing wrong, think i've distilled downwards few lines of code seem me should work. think essential problem in authentication, i've given thought may way i'm trying phone call service manager routine via soap.

here's first method found:

#!/usr/local/perl5/bin/perl utilize soap::lite+trace => 'all'; $user = "working_user_name"; $pass = "working_password"; sub soap::transport::http::client::get_basic_credentials { print "###\n"; print "###\n"; print "### authenticating...\n"; print "###\n"; print "###\n"; homecoming $user => $pass; } $soap = soap::lite->new(proxy => 'http://<hp_service_manager>:13080/sm/7/ws'); $soap->default_ns('http://schemas.hp.com/sm/7'); $som = $soap->call('retrievelist'); die $som->faultstring if ($som->fault); print $som->result, "\n";

and lwp method tried:

#!/usr/local/perl5/bin/perl utilize soap::lite+trace => 'all'; utilize lwp::useragent; utilize lwp::debug; lwp::debug::level('+'); $user = "working_user_name"; $pass = "working_password"; @ua_args = (keep_alive => 1); @credentials = ($service_ns, "", $user, $pass); $schema_ua = lwp::useragent->new(@ua_args); $schema_ua->credentials(@credentials); $soap = soap::lite->new(proxy => 'http://<hp_service_manager>:13080/sm/7/ws', @ua_args, credentials => \@credentials); $soap->default_ns('http://schemas.hp.com/sm/7'); $som = $soap->call('retrievelist'); die $som->faultstring if ($som->fault); print $som->result, "\n";

the issue no matter "not authorized" return. it's hp service manager installation. i'll provide wsdl entry i'm trying do. uncertainty it's useful.

<soap:operation soapaction="retrievelist" style="document"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation>

while there lot more came from, pertinent output, believe:

soap::transport::http::client::send_receive: http::request=hash(0x845c630) soap::transport::http::client::send_receive: post http://<service_manager>:13080/sm/7/ws http/1.1 accept: text/xml accept: multipart/* content-length: 488 content-type: text/xml; charset=utf-8 soapaction: "#default_ns" <?xml version="1.0" encoding="utf-8"?><soap-env:envelope xmlns:xsi="http://www.w3.org/1999/xmlschema-instance" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/xmlschema" soap-env:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"><soap-env:body><default_ns><c-gensym3 xsi:type="xsd:string">http://schemas.hp.com/sm/7</c-gensym3></default_ns></soap-env:body></soap-env:envelope> soap::transport::http::client::send_receive: http::response=hash(0x8597238) soap::transport::http::client::send_receive: http/1.1 401 unauthorized connection: close date: fri, 15 feb 2013 19:42:06 gmt server: apache-coyote/1.1 www-authenticate: basic realm="casm" content-length: 40 content-type: text/html;charset=utf-8 client-date: fri, 15 feb 2013 19:42:07 gmt client-peer: nnn.nn.nn.nn:13080 client-response-num: 1 <html><body>not authorized</body></html>

can help? i've tried pretty much every illustration i've been able find, , tried variations of examples, , i've never managed futher. in every case "not authorized" return.

thanks,

sean.

don't mislead: soap::lite's debugging output doesn't show authorization header (for reason?).

the "overriding get_basic_credentials"-method globally sets username/password, regardless of domain , realm. bad thing...

this (tested) piece of code should prepare issue:

#!/usr/local/perl5/bin/perl -w utilize strict; utilize soap::lite+trace => 'all'; $soap = soap::lite->new('proxy' => [ 'http://<yourdomain>:<yourport>/<yourpath>', 'credentials' => [ "<yourdomain>:<yourport>", "<yourrealm>", "<yourusername>", "<yourpassword>" ] ]); $som = $soap->retrievelist(); die $som->faultstring if ($som->fault); print $som->result, "\n";

where "<yourrealm>" should set "casm", "<yourpath>" should set "/sm/7/ws", "<yourport>" should set "13080".

old reply: seek doing instead (note asterisk):

*soap::transport::http::client::get_basic_credentials = sub { homecoming ($user, $pass); }

perl soap authorization

No comments:

Post a Comment