title: Perl SOAP::LITE -- can't authenticate?
body: <p>I'm trying -- and failing -- to write a simple test app using SOAP::LITE to access an HP Service Manager site. (I've also tried SOAP::WSDL, but further reading made me believe that it really isn't required for what I want to do.)</p>
  
  <p>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.</p>
  
  <p>Here's the first method I found:</p>
  
  <pre><code>#!/usr/local/perl5/bin/perl
  use SOAP::Lite+trace =&gt; '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 =&gt; $PASS;
  }
  
  
  my $soap = SOAP::Lite-&gt;new(proxy =&gt; 'http://&lt;hp_service_manager&gt;:13080/SM/7/ws');
  $soap-&gt;default_ns('http://schemas.hp.com/SM/7');
  my $som = $soap-&gt;call('RetrieveList');
  die $som-&gt;faultstring if ($som-&gt;fault);
  print $som-&gt;result, "\n";
  </code></pre>
  
  <p>And the LWP method I tried:</p>
  
  <pre><code>#!/usr/local/perl5/bin/perl
  use SOAP::Lite+trace =&gt; 'all';
  use LWP::UserAgent;
  use LWP::Debug;
  LWP::Debug::level('+');
  
  $USER = "working_user_name";
  $PASS = "working_password";
  
  my @ua_args = (keep_alive =&gt; 1);
  my @credentials = ($SERVICE_NS, "", $USER, $PASS);
  my $schema_ua = LWP::UserAgent-&gt;new(@ua_args);
  $schema_ua-&gt;credentials(@credentials);
  
  my $soap = SOAP::Lite-&gt;new(proxy =&gt; 'http://&lt;hp_service_manager&gt;:13080/SM/7/ws', @ua_args, credentials =&gt; \@credentials);
  $soap-&gt;default_ns('http://schemas.hp.com/SM/7');
  my $som = $soap-&gt;call('RetrieveList');
  die $som-&gt;faultstring if ($som-&gt;fault);
  print $som-&gt;result, "\n";
  </code></pre>
  
  <p>The issue is that no matter what I do I get a "not authorized" return. 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.</p>
  
  <pre><code>&lt;soap:operation soapAction="RetrieveList" style="document"/&gt;
  &lt;input&gt;
  &lt;soap:body use="literal"/&gt;
  &lt;/input&gt;
  &lt;output&gt;
  &lt;soap:body use="literal"/&gt;
  &lt;/output&gt;
  &lt;/operation&gt;
  </code></pre>
  
  <p>While there is a lot more where this came from, this is the pertinent output, I believe:</p>
  
  <pre><code>SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x845c630)
  SOAP::Transport::HTTP::Client::send_receive: POST http://&lt;service_manager&gt;: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"
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;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/"&gt;&lt;SOAP-ENV:Body&gt;&lt;default_ns&gt;&lt;c-gensym3 xsi:type="xsd:string"&gt;http://schemas.hp.com/SM/7&lt;/c-gensym3&gt;&lt;/default_ns&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  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
  
  &lt;HTML&gt;&lt;BODY&gt;Not Authorized&lt;/BODY&gt;&lt;/HTML&gt;
  </code></pre>
  
  <p>Can anyone help?  I've tried pretty much every example I've been able to find, and then tried variations of those examples, and I've never managed to get any futher.  In every case I get a "Not Authorized" return.</p>
  
  <p>Thanks,</p>
  
  <p>Sean.</p>