Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Help with SOAP::LITE

by slgilley (Initiate)
on Feb 14, 2013 at 19:08 UTC ( #1018768=perlquestion: print w/ replies, xml ) Need Help??
slgilley has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying -- and failing -- to write a simple test app using SOAP::LITE. (I've also tried SOAP::WSDL, but further reading made me believe that it really isn't required for what I want to do.)

I'm new to SOAP, new to these packages, and new to what I'm trying to do, so I don't know how many things I'm doing wrong, but I think I've distilled it down to a few lines of code that seem to me should work. I think the essential problem is in authentication, but I've also given some thought that it may be the way I'm trying to call the service manager routine via SOAP.

Here's the first method I found:

#!/usr/local/perl5/bin/perl use 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"; return $USER => $PASS; } my $soap = SOAP::Lite->new(proxy => 'http://<hp_service_manager>:13080 +/SM/7/ws'); $soap->default_ns('http://schemas.hp.com/SM/7'); my $som = $soap->call('RetrieveList'); die $som->faultstring if ($som->fault); print $som->result, "\n";

And the LWP method I tried:

#!/usr/local/perl5/bin/perl use SOAP::Lite+trace => 'all'; use LWP::UserAgent; use LWP::Debug; LWP::Debug::level('+'); $USER = "working_user_name"; $PASS = "working_password"; my @ua_args = (keep_alive => 1); my @credentials = ($SERVICE_NS, "", $USER, $PASS); my $schema_ua = LWP::UserAgent->new(@ua_args); $schema_ua->credentials(@credentials); my $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'); my $som = $soap->call('RetrieveList'); die $som->faultstring if ($som->fault); print $som->result, "\n";

Can anyone help? This is becoming extremely frustrating. I can't find examples, or if I can, they aren't completely clear to me because I'm not sure I fully understand things like "endpoint", "namespace", "uri", and "urn".

Edit: The issue is that no matter what I do I get a "not authorized" return. No live URLs, as this is a business, and even assuming I gave you one, you couldn't get here. (Not to mention inviting people to try breaking in would probably get me fired.) It's an HP Service Manager installation. I'll provide the WSDL entry for what I'm trying to do. I doubt it's useful.

<soap:operation soapAction="RetrieveList" style="document"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation>

While there is a lot more where this came from, this is the pertinent output, I believe:

SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x845c +630) SOAP::Transport::HTTP::Client::send_receive: POST http://<service_mana +ger>: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="ht +tp://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schem +as.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap +.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOA +P-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:Envel +ope> SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x859 +7238) 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: 134.243.93.19:13080 Client-Response-Num: 1 <HTML><BODY>Not Authorized</BODY></HTML>

Thanks, Sean.

Comment on Help with SOAP::LITE
Select or Download Code
Re: Help with SOAP::LITE
by Anonymous Monk on Feb 15, 2013 at 17:05 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1018768]
Approved by ww
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-11-24 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (137 votes), past polls