SOAP::Lite proxied

Discussion in 'Perl Misc' started by Ian Wilson, Jun 29, 2005.

  1. Ian Wilson

    Ian Wilson Guest

    I have a SOAP client using SOAP::Lite whose only access to a SOAP
    service is through an HTTP Proxy.

    On one Unix system the client will use the proxy if the environment
    variable HTTP_proxy is set. It will authenticate to the proxy if the
    environment variables HTTP_proxy_use and HTTP_proxy_pass are set.

    On another Unix system, setting the environment variables seems to have
    no effect. Same operating system, same versions of Perl (5.8.0) and
    SOAP::Lite ($Id 1.47 in Lite.pm).

    I'm using +trace but can't see why the environment variables are not
    used. Any ideas?


    With LWP::UserAgent, you can also do things like
    $ua->proxy('http'=>'http://proxy.server:8080');
    $request->proxy_authorization_basic('fred', 'secret');
    Is there any way to do something equivalent using SOAP::Lite?
    Ian Wilson, Jun 29, 2005
    #1
    1. Advertising

  2. Ian Wilson

    Guest

    Gee, I cant belive someone hasnt given you the "plese post to the
    proper newsgroup" diatribe that never seems to get old here. Anyways,
    how and where are U "setting the environment" vars? This goes 4 both
    systems.
    , Jun 30, 2005
    #2
    1. Advertising

  3. Ian Wilson <> wrote in
    news:d9tq3u$k3n$-infra.bt.com:

    > With LWP::UserAgent, you can also do things like
    > $ua->proxy('http'=>'http://proxy.server:8080');
    > $request->proxy_authorization_basic('fred', 'secret');
    > Is there any way to do something equivalent using SOAP::Lite?


    Are you asking us to look up documentation for you?

    http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm

    <blockquote>
    In addition to endpoint parameter, proxy() can accept any transport
    specific parameters that could be passed as name => value pairs. For
    example, to specify proxy settings for HTTP protocol you may do:

    $soap->proxy('http://endpoint.server/',
    proxy => ['http' => 'http://my.proxy.server/']);
    </blockquote>

    Now, I have never tried this, and I don't know if it works, but I would
    have expected you to at least attempt it yourself, and provide a minimal
    but complete script that still exhibits the problem.

    Please read the posting guidelines for this group to learn how you can
    help yourself and help others help you.

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Jun 30, 2005
    #3
  4. <> wrote:

    > Gee, I cant belive someone hasnt given you the "plese post to the
    > proper newsgroup" diatribe that never seems to get old here.



    Gee, I can believe that I've found yet another GF[1] to killfile!



    [1] The G is for Google.

    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jun 30, 2005
    #4
  5. Ian Wilson

    Ian Wilson Guest

    wrote:
    > Gee, I cant belive someone hasnt given you the "plese post to the
    > proper newsgroup" diatribe that never seems to get old here. Anyways,
    > how and where are U "setting the environment" vars? This goes 4 both
    > systems.
    >


    Korn shell:
    export HTTP_proxy=http://proxy.example.com \
    HTTP_proxy_user=foo \
    HTTP_proxy_pass=bar

    C shell:
    setenv HTTP_proxy http://proxy.example.com
    setenv HTTP_proxy_user foo
    setenv HTTP_proxy_user bar

    In my perl SOAP client I check this using something like:
    #!/usr/bin/perl
    use strict;
    use warnings;
    print "HTTP_proxy is '$ENV{HTTP_proxy}'\n";
    which prints the expected results.

    My question wasn't about how to set environment variables. But thanks
    for taking the trouble to reply.
    Ian Wilson, Jun 30, 2005
    #5
  6. Ian Wilson

    Ian Wilson Guest

    A. Sinan Unur wrote:
    > Ian Wilson <> wrote in
    > news:d9tq3u$k3n$-infra.bt.com:
    >
    >
    >> With LWP::UserAgent, you can also do things like
    >> $ua->proxy('http'=>'http://proxy.server:8080');
    >> $request->proxy_authorization_basic('fred', 'secret'); Is there any
    >> way to do something equivalent using SOAP::Lite?

    >
    >
    > Are you asking us to look up documentation for you?


    Certainly not! My apologies for not stating that I had already read that
    document.

    > http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm
    >
    > <blockquote> In addition to endpoint parameter, proxy() can accept
    > any transport specific parameters that could be passed as name =>
    > value pairs. For example, to specify proxy settings for HTTP protocol
    > you may do:
    >
    > $soap->proxy('http://endpoint.server/', proxy => ['http' =>
    > 'http://my.proxy.server/']); </blockquote>


    I hadn't found anywhere in that document where it explains how to set
    the credentials required by the proxy for authorization - i.e. a user-ID
    and password (for the HTTP proxy, not the endpoint).

    There are however some clues in the soaplite cookbook, I have tried all
    of these. I will follow-up with some sanitized code later.

    I have tried, for example:
    $soap->proxy('http://user:p/',
    proxy => ['http' => 'http://my.proxy.server/']);
    and
    $soap->proxy('http://endpoint.server/',
    proxy => ['http' => 'http://user:p/']);

    The former is suggested in the cookbook. It seems like it should
    authenticate to the endpoint not to the HTTP proxy so I tried the latter
    variant as well.

    > Now, I have never tried this, and I don't know if it works, but I
    > would have expected you to at least attempt it yourself,


    You are right to expect this and I have indeed tried a half dozen
    variants of this, I should have said so (I worry that long posts tend to
    make people's eyes glaze over)

    I also checked what is happening with "use SOAP::Lite +trace;"
    concurrently with a "tail -f /var/log/squid/access.log" at the HTTP
    proxy server. I have used wget and a perl script using LWP::Useragent to
    check the proxy and endpoint logging, use of environment variables,
    explicit setting of credentials, etc. This would be a lot to post so
    instead I'll construct a minimal example that readers could run.

    > and provide a minimal but complete script that still exhibits the
    > problem.


    Will do, once I have found (or created) a public SOAP endpoint that I
    can use for this purpose.
    Ian Wilson, Jun 30, 2005
    #6
  7. Ian Wilson

    Ian Wilson Guest

    A. Sinan Unur wrote:
    > Ian Wilson <> wrote in
    > news:d9tq3u$k3n$-infra.bt.com:
    >
    >
    >> With LWP::UserAgent, you can also do things like
    >> $ua->proxy('http'=>'http://proxy.server:8080');
    >> $request->proxy_authorization_basic('fred', 'secret'); Is there any
    >> way to do something equivalent using SOAP::Lite?

    >
    >
    > I would have expected you to ... provide a minimal but complete
    > script that still exhibits the problem.
    >


    As should have been evident from my original post. I have code that
    retrieves the correct result on one computer but not when run on another
    computer (both same flavour of Unix) - so I'd not expect to find a fatal
    error in the Perl scripts below.

    On computer-A, with proxy-A, the clients return
    ...
    "37.5 C = 99.5 F"

    On computer-B, with proxy-B, the clients fail:
    ...
    "407 Proxy Authentication Required"


    client1 - relies on (undocumented?) environment variables
    Korn shell:
    export HTTP_proxy=http://proxy.example.com \
    HTTP_proxy_user=Dirk \
    HTTP_proxy_pass=foo
    ../soaptempclient1.pl
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    #!/usr/bin/perl -w
    use strict;
    use warnings;
    use SOAP::Lite;

    my $c = shift @ARGV;
    $c = 37.5 unless $c;

    foreach (qw(HTTP_proxy HTTP_proxy_user HTTP_proxy_pass)) {
    print "$_='$ENV{$_}'\n" unless not defined $ENV{$_};
    }

    print
    "$c C = ",
    SOAP::Lite
    -> uri('http://www.example.org/Temperatures')
    -> proxy ('http://www.example.org/cgi-bin/soaptemp.pl')
    -> c2f($c)
    -> result,
    " F\n";
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

    client2 explicitly sets credentials using an approach that is not
    explicitly documented anywhere I have found so far. Note that the user
    and password for the HTTP proxy are "Dirk" and "foo" respectively. The
    SOAP endpoint does not require authentication.
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    #!/usr/bin/perl -w
    use strict;
    use warnings;
    use SOAP::Lite;

    my $c = shift @ARGV;
    $c = 37.5 unless $c;

    foreach (qw(HTTP_proxy HTTP_proxy_user HTTP_proxy_pass)) {
    print "$_='$ENV{$_}'\n" unless not defined $ENV{$_};
    }

    print
    "$c C = ",
    SOAP::Lite
    -> uri('http://www.example.org/Temperatures')
    -> proxy ('http://www.example.org/cgi-bin/soaptemp.pl',
    proxy => ['http' => 'http://Dirk:foo@12.34.56.78:8080'])
    -> c2f($c)
    -> result,
    " F\n";
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

    server script soaptemp.pl
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    #!/usr/bin/perl -w

    use SOAP::Transport::HTTP;

    SOAP::Transport::HTTP::CGI
    -> dispatch_to('Temperatures')
    -> handle;

    package Temperatures;

    sub f2c {
    my ($class, $f) = @_;
    return 5/9*($f-32);
    }

    sub c2f {
    my ($class, $c) = @_;
    return 32+$c*9/5;
    }
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

    For proxy-A, I use Squid. In squid.conf I added
    authenticate_program /usr/local/bin/squidauth.pl
    acl authentic proxy_auth REQUIRED
    http_access allow authentic
    http_access deny all
    proxy_auth_realm Ians Proxy

    squidauth.pl (verbatim from squid docs) is
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    #!/usr/bin/perl -w
    $|=1; # no buffering, important!
    while (<>) {
    chop;
    ($u,$p) = split;
    $ans = &check($u,$p);
    print "$ans\n";
    }

    sub check {
    local($u,$p) = @_;
    return 'ERR' unless (defined $p && defined $u);
    return 'OK' if ('Dirk' eq $u);
    return 'OK' if ('Sekrit' eq $p);
    return 'ERR';
    }
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

    I'll have to get the proxy-B administrator to check that it accepts
    basic authentication (as opposed to NTLM, Digest or others only)

    In my view, HTTP-proxy authentication *could* be better documented in
    the SOAP::Lite docs. YMMV.
    Ian Wilson, Jun 30, 2005
    #7
  8. Ian Wilson <> wrote in
    news:da0bqv$4ih$-infra.bt.com:

    > A. Sinan Unur wrote:
    >> Ian Wilson <> wrote in
    >> news:d9tq3u$k3n$-infra.bt.com:
    >>
    >>
    >>> With LWP::UserAgent, you can also do things like
    >>> $ua->proxy('http'=>'http://proxy.server:8080');
    >>> $request->proxy_authorization_basic('fred', 'secret'); Is there any
    >>> way to do something equivalent using SOAP::Lite?

    >>
    >>
    >> Are you asking us to look up documentation for you?

    >
    > Certainly not! My apologies for not stating that I had already read
    > that document.


    OK, sorry about that. So many people do post without looking that if it
    is not explicitly stated, I tend to assume they haven't/

    >> http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm
    >>
    >> <blockquote> In addition to endpoint parameter, proxy() can accept
    >> any transport specific parameters that could be passed as name =>
    >> value pairs. For example, to specify proxy settings for HTTP protocol
    >> you may do:
    >>
    >> $soap->proxy('http://endpoint.server/', proxy => ['http' =>
    >> 'http://my.proxy.server/']); </blockquote>

    >
    > I hadn't found anywhere in that document where it explains how to set
    > the credentials required by the proxy for authorization - i.e. a
    > user-ID and password (for the HTTP proxy, not the endpoint).


    Hmmm ... I can't either. On the other hand,

    http://search.cpan.org/~byrne/SOAP-Lite-
    0.60a/lib/SOAP/Transport/HTTP.pm#PROXY_SETTINGS

    does have a section on it. The key phrase seems to be:

    <quote>
    You can use any proxy setting you use with LWP::UserAgent modules:
    </quote>

    Unfortunately, LWP::UserAgent docs do not give much information either.

    However, here is the relevant snippet from SOAP::Transport::HTTP:

    my $req = HTTP::Request->new($method => $endpoint,
    (defined $headers ? $headers : HTTP::Headers->new),
    $req->protocol('HTTP/1.1');

    $req->proxy_authorization_basic(
    $ENV{'HTTP_proxy_user'},
    $ENV{'HTTP_proxy_pass'}
    ) if ($ENV{'HTTP_proxy_user'}
    && $ENV{'HTTP_proxy_pass'}
    );

    (source reformatted to fit).

    This leads me to believe the environment variable method should work.

    > $soap->proxy('http://endpoint.server/',
    > proxy => ['http' => 'http://user:p/']);


    And, this should work as well:

    <URL:http://search.cpan.org/~byrne/SOAP-Lite-
    0.60a/lib/SOAP/Transport/HTTP.pm#SYNOPSIS>

    So, I am not sure how I could help you with the problem (it seems like
    this is an issue caused by something other than SOAP::Lite), especially
    since I do not have a setup where I can try things.

    I would focus on the differences rather than the similarities between
    the two systems. Are two systems going through the same proxy?

    Sinan
    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Jun 30, 2005
    #8
  9. Ian Wilson

    Ian Wilson Guest

    A. Sinan Unur wrote:
    > Ian Wilson <> wrote in
    > news:da0bqv$4ih$-infra.bt.com:
    >
    >


    <snip: Discussion of how to set user and password for HTTP-proxy when
    using SOAP::Lite>

    To summarise, you can either set environment variables HTTP_proxy,
    HTTP_proxy_user and HTTP_proxy_pass or you can use a construct like:
    $soap->proxy('http://endpoint.server/',
    proxy => ['http' => 'http://user:p/']);

    >
    > I would focus on the differences rather than the similarities between
    > the two systems. Are two systems going through the same proxy?


    They use different proxies. I'm now almost certain the problem lies with
    configuration of the other proxy, which means it isn't a Perl problem
    despite my earlier difficulty in finding out exactly how
    authenticated-proxies are meant to work in SOAP::Lite.

    Thanks for your help - much appreciated.
    Ian Wilson, Jun 30, 2005
    #9
  10. writes:

    > Gee, I hope U -err- you, append the entry[1] with Perl......
    >
    >
    > [1] This note denotes my broken heart


    Lovely attitude you have there. Hope it answers your Perl questions for you.

    *plonk*

    sherm--

    --
    Due to the amount of unreadable gibberish being posted from Google Groups,
    I seldom read messages posted from there.

    Cocoa/Perl: http://camelbones.sf.net Hire Me: http://www.dot-app.org
    Sherm Pendley, Jul 1, 2005
    #10
  11. Ian Wilson

    Guest

    Tad McClellan wrote:
    > <> wrote:
    >
    > > Gee, I cant belive someone hasnt given you the "plese post to the
    > > proper newsgroup" diatribe that never seems to get old here.

    >
    >
    > Gee, I can believe that I've found yet another GF[1] to killfile!
    >
    >
    >
    > [1] The G is for Google.
    >
    > --
    > Tad McClellan SGML consulting
    > Perl programming
    > Fort Worth, Texas


    Gee, I hope U -err- you, append the entry[1] with Perl......


    [1] This note denotes my broken heart
    , Jul 1, 2005
    #11
  12. Ian Wilson

    Big and Blue Guest

    Ian Wilson wrote:
    >
    > I hadn't found anywhere in that document where it explains how to set
    > the credentials required by the proxy for authorization - i.e. a user-ID
    > and password (for the HTTP proxy, not the endpoint).


    I have problems trying to remember what to do here too.

    And, at least with LWP, if not with SOAP (I don't know), there is a
    difference between using the function calls to set a proxy and setting
    environment variables. It applies to HTTPS calls. One will end up doing a
    GET and the other a CONNECT through the proxy (IIRC I have to set the
    environment variables in order to use CONNECT, which is what is needed for
    teh proxy I use). And I've never found any documentations in the modules
    there as to the difference and the effect. Discovered by trial, error some
    network snooping and a helpful proxy admin who made some comments on the
    log entries I generated.


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue, Jul 2, 2005
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Saqib Ali

    SOAP:Lite Limitations re: https??

    Saqib Ali, Sep 12, 2003, in forum: Perl
    Replies:
    1
    Views:
    3,021
    Serge Dubrouski
    Sep 16, 2003
  2. Blaine Everingham

    SOAP::Lite

    Blaine Everingham, Dec 9, 2003, in forum: Perl
    Replies:
    0
    Views:
    711
    Blaine Everingham
    Dec 9, 2003
  3. Rushikesh Joshi
    Replies:
    0
    Views:
    428
    Rushikesh Joshi
    Aug 19, 2004
  4. Aaron Brady

    SQL, lite lite lite

    Aaron Brady, Dec 29, 2008, in forum: Python
    Replies:
    15
    Views:
    738
    Aaron Brady
    Jan 1, 2009
  5. droesler
    Replies:
    2
    Views:
    473
    droesler
    Aug 31, 2010
Loading...

Share This Page