Hello, I am rewriting some old code and want to create a SOAP request with username and password. I know that if I used SOAP::Lite I would override this method
BEGIN { sub SOAP::Transport::HTTP::Client::get_basic_credentials { return 'username' => 'password'; } }
But this code is usgin SOAP::WSDL and I cannot get it right - I always get error from server: "401 - Unauthorized: Access is denied due to invalid credentials". When I post the request with Curl from command line everything works. The server administrator told me that from logs it seems like I am not providing credentials. So far I have this:
$service = MyInterfaces::AccMgrWS::AccMgrWSSoap->new({proxy => [$url, +keep_alive => 1]}); my @headers = ( SOAP::Header->name('username')->value($user), SOAP::Header->name('password')->value($pass), ); my $result = $service->GetSometing(undef, \@headers);
AccMgrWSSoap is a class that inherits from SOAP::WSDL::Client::Base and GetSometing looks like this:
sub GetSometing { my ($self, $body, $header) = @_; die "GetSometing must be called as object method (\$self is <$self +>)" if not blessed($self); return $self->SUPER::call({ operation => 'GetSometing', soap_action => 'http://www.some.address/GetSometing', style => 'document', body => { 'use' => 'literal', namespace => 'http://schemas.xmlsoap.org/wsdl/soap/' +, encodingStyle => '', parts => [qw( MyElements::GetSometing )], }, header => { }, headerfault => { } }, $body, $header); }
Any ideas how can I make this work? Thank you

In reply to SOAP::WSDL authentication by Stetec

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.