title: Using Perl LWP::UserAgent with XML that requires Usernames and Passwords to connect
body: <p>OK... I'm trying to post an XML page to a strategic partner's site for them to do some calculations and return me a response code, again via XML.</p>
  
  <p>I'm using garden-variety PERL, and was trying to use LWP::UserAgent to do this... if there is a more elegant way, please point me in that direction.</p>
  
  <p>I'm able to hit their server, and get a code back... but it denies access to their server because the username and password it is expecting is not correct.  The username and password are not specified in the actual XML code, it is supposed to be passed to the server as part of the actual POST method... but I have no clue how to do that.</p>
  
  <p>The partner gives the following feedback:</p>
  
  <blockquote>
    <p>replacing the YOUR_XML_FILE, YOUR_USER and YOUR_PASSWORD with his xml
    that gets generated, and his username/password combination.  This
    should be done from the server that he has his perl script.</p>
    
    <p>wget --no-check-certificate --post-file YOUR_XML_FILE
    <a href="https://previewtest.clverify.com/webservice/exec" rel="nofollow">https://previewtest.clverify.com/webservice/exec</a> -O
    previewsamplerequest.response.xml --http-user=YOUR_USER
    --http-password=YOUR_PASSWORD</p>
  </blockquote>
  
  <p>I don't know where this is supposed to be generated, or what the options are in LWP::UserAgent to specify them.  Has anyone out there done this before?  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>sub ConsumerInfo {
  my $cid = shift;
  
  my $response = undef;
  my $sendXML = &amp;Create_ConsumerInfo_Request($cid);
  if ($sendXML) {
      &amp;DoXMLUpload($sendXML);
  
      my $browser = LWP::UserAgent-&gt;new(agent =&gt; 'perl post');
      $browser-&gt;credentials('','','username','p@ssword');
      $response = $browser-&gt;request(POST 'https://previewtest.clverify.com/webservice/exec',
          Content_Type =&gt; 'text/xml',
          Content =&gt; $sendXML);
      print "Content-type:text/html\n\n";
      print $response-&gt;error_as_HTML unless $response-&gt;is_success;
      print $response-&gt;as_string;
  
  } else {
      &amp;ErrorMsg("No XML Code Was Found.");
      exit;   
  }
  # ===============================================================
  # Need to insert parser in here to convert this into an array.
  # ===============================================================
  return $response;
  }
  </code></pre>