Call Web Service using proxy and http authentication

Discussion in 'Python' started by wdveloper, May 12, 2009.

  1. wdveloper

    wdveloper Guest

    Hi everyone,

    I am trying to call a webservice which requires an http
    authentication.
    To reach the ws, I must pass from a proxy http. So in the whole I need
    go through two authentications before getting the ws working. I am
    using SOAPpy and I'm getting quite crazy.
    I am able to arrange this problem with simple http calls using urllib2
    but for the ws i dont see any way out.

    Does anyone knows how I can manage this stuff? Is there any better
    solution or example code?

    Thanks very much for your help,
    totobe
     
    wdveloper, May 12, 2009
    #1
    1. Advertising

  2. wdveloper

    Steve Howell Guest

    On May 12, 8:59 am, wdveloper <> wrote:
    > Hi everyone,
    >
    > I am trying to call a webservice which requires an http
    > authentication.
    > To reach the ws, I must pass from a proxy http. So in the whole I need
    > go through two authentications before getting the ws working. I am
    > using SOAPpy and I'm getting quite crazy.
    > I am able to arrange this problem with simple http calls using urllib2
    > but for the ws i dont see any way out.
    >
    > Does anyone knows how I can manage this stuff? Is there any better
    > solution or example code?
    >


    Your high level description of the problem is good, but I think you'll
    get more help if you provide a little more detail.

    For something like this you may want to try to do more at the HTTP
    level, where you have a little more control over the authentication,
    and then find a way to hook into SOAPpy just to build and parse the
    payloads.

    How good is your understanding of HTTP? Do you know the basics of how
    headers work? You might want to brush up a little on HTTP just to
    help understand what's going on; it will almost certainly be valuable
    for future projects as well.

    To understand how the proxy works in particular, if you can use the
    proxy to access a normal html-serving website, you can use the "Live
    HTTP Headers" tool under Firefox to see what's going on.

    But before all that, I would maybe just post a little more detail on
    the problem. Maybe show code you've written so far, and any error
    messages/tracebacks, to better indicate where you are stuck.
     
    Steve Howell, May 12, 2009
    #2
    1. Advertising

  3. wdveloper

    wdveloper Guest

    On May 12, 8:38 pm, Steve Howell <> wrote:
    > On May 12, 8:59 am, wdveloper <> wrote:
    >
    > > Hi everyone,

    >
    > > I am trying to call a webservice which requires an http
    > > authentication.
    > > To reach the ws, I must pass from a proxy http. So in the whole I need
    > > go through two authentications before getting the ws working. I am
    > > using SOAPpy and I'm getting quite crazy.
    > > I am able to arrange this problem with simple http calls using urllib2
    > > but for the ws i dont see any way out.

    >
    > > Does anyone knows how I can manage this stuff? Is there any better
    > > solution or example code?

    >
    > Your high level description of the problem is good, but I think you'll
    > get more help if you provide a little more detail.
    >
    > For something like this you may want to try to do more at the HTTP
    > level, where you have a little more control over the authentication,
    > and then find a way to hook into SOAPpy just to build and parse the
    > payloads.
    >
    > How good is your understanding of HTTP?  Do you know the basics of how
    > headers work?  You might want to brush up a little on HTTP just to
    > help understand what's going on; it will almost certainly be valuable
    > for future projects as well.
    >
    > To understand how the proxy works in particular, if you can use the
    > proxy to access a normal html-serving website, you can use the "Live
    > HTTP Headers" tool under Firefox to see what's going on.
    >
    > But before all that, I would maybe just post a little more detail on
    > the problem.  Maybe show code you've written so far, and any error
    > messages/tracebacks, to better indicate where you are stuck.


    Thank you very much Steve,

    I do have a good understanding of http and its headers rules, and of
    course I can work on that.
    On the other hand, I am new to python and SOAPpy toolkit and I dont
    have much of an experience working with ws in general.

    When it comes of working with simple call to WS, everything is
    successfull; problems start cause I dont know how to use the toolkit
    to compose the http request. I should code it in the way that it
    connects to my proper proxy and it gets authenticated in the server
    exposing the service.

    What I have is something like:
    from SOAPpy import WSDL

    wsdl = 'http://myws?wsdl'
    my_http_proxy = '10.x.x.x:8080'
    proxy = WSDL.Proxy(wsdl, http_proxy=my_http_proxy)
    res = proxy.myService( myparam='...' )

    What I get is that connection reaches timeout since the server doesnt
    see me coming from the right proxy.
    First problem, I can't see where I can put my proxy authentication
    username and password.
    Second, when I will be able to pass through the right proxy, I need to
    authenticate on the server via http through my credential.

    I am starting wondering whether python+SOAPpy is the right solution or
    I need to switch to other solutions (zsi?).

    I hope I've been more detailed now and my situation sounds little more
    clear.
    Thanks again for your precious help!
     
    wdveloper, May 12, 2009
    #3
  4. wdveloper

    Steve Howell Guest

    On May 12, 12:51 pm, wdveloper <> wrote:
    > On May 12, 8:38 pm, Steve Howell <> wrote:
    >
    >
    >
    > > On May 12, 8:59 am, wdveloper <> wrote:

    >
    > > > Hi everyone,

    >
    > > > I am trying to call a webservice which requires an http
    > > > authentication.
    > > > To reach the ws, I must pass from a proxy http. So in the whole I need
    > > > go through two authentications before getting the ws working. I am
    > > > using SOAPpy and I'm getting quite crazy.
    > > > I am able to arrange this problem with simple http calls using urllib2
    > > > but for the ws i dont see any way out.

    >
    > > > Does anyone knows how I can manage this stuff? Is there any better
    > > > solution or example code?

    >
    > > Your high level description of the problem is good, but I think you'll
    > > get more help if you provide a little more detail.

    >
    > > For something like this you may want to try to do more at the HTTP
    > > level, where you have a little more control over the authentication,
    > > and then find a way to hook into SOAPpy just to build and parse the
    > > payloads.

    >
    > > How good is your understanding of HTTP?  Do you know the basics of how
    > > headers work?  You might want to brush up a little on HTTP just to
    > > help understand what's going on; it will almost certainly be valuable
    > > for future projects as well.

    >
    > > To understand how the proxy works in particular, if you can use the
    > > proxy to access a normal html-serving website, you can use the "Live
    > > HTTP Headers" tool under Firefox to see what's going on.

    >
    > > But before all that, I would maybe just post a little more detail on
    > > the problem.  Maybe show code you've written so far, and any error
    > > messages/tracebacks, to better indicate where you are stuck.

    >
    > Thank you very much Steve,
    >
    > I do have a good understanding of http and its headers rules, and of
    > course I can work on that.
    > On the other hand, I am new to python and SOAPpy toolkit and I dont
    > have much of an experience working with ws in general.
    >
    > When it comes of working with simple call to WS, everything is
    > successfull; problems start cause I dont know how to use the toolkit
    > to compose the http request. I should code it in the way that it
    > connects to my proper proxy and it gets authenticated in the server
    > exposing the service.
    >
    > What I have is something like:
    > from SOAPpy import WSDL
    >
    > wsdl = 'http://myws?wsdl'
    > my_http_proxy = '10.x.x.x:8080'
    > proxy = WSDL.Proxy(wsdl, http_proxy=my_http_proxy)
    > res = proxy.myService( myparam='...' )
    >
    > What I get is that connection reaches timeout since the server doesnt
    > see me coming from the right proxy.
    > First problem, I can't see where I can put my proxy authentication
    > username and password.
    > Second, when I will be able to pass through the right proxy, I need to
    > authenticate on the server via http through my credential.
    >



    Have you looked at the URLopener class?
     
    Steve Howell, May 13, 2009
    #4
  5. wdveloper

    wdveloper Guest

    On May 13, 5:26 pm, Steve Howell <> wrote:
    > On May 12, 12:51 pm, wdveloper <> wrote:
    >
    >
    >
    > > On May 12, 8:38 pm, Steve Howell <> wrote:

    >
    > > > On May 12, 8:59 am, wdveloper <> wrote:

    >
    > > > > Hi everyone,

    >
    > > > > I am trying to call a webservice which requires an http
    > > > > authentication.
    > > > > To reach the ws, I must pass from a proxy http. So in the whole I need
    > > > > go through two authentications before getting the ws working. I am
    > > > > using SOAPpy and I'm getting quite crazy.
    > > > > I am able to arrange this problem with simple http calls using urllib2
    > > > > but for the ws i dont see any way out.

    >
    > > > > Does anyone knows how I can manage this stuff? Is there any better
    > > > > solution or example code?

    >
    > > > Your high level description of the problem is good, but I think you'll
    > > > get more help if you provide a little more detail.

    >
    > > > For something like this you may want to try to do more at the HTTP
    > > > level, where you have a little more control over the authentication,
    > > > and then find a way to hook into SOAPpy just to build and parse the
    > > > payloads.

    >
    > > > How good is your understanding of HTTP?  Do you know the basics of how
    > > > headers work?  You might want to brush up a little on HTTP just to
    > > > help understand what's going on; it will almost certainly be valuable
    > > > for future projects as well.

    >
    > > > To understand how the proxy works in particular, if you can use the
    > > > proxy to access a normal html-serving website, you can use the "Live
    > > > HTTP Headers" tool under Firefox to see what's going on.

    >
    > > > But before all that, I would maybe just post a little more detail on
    > > > the problem.  Maybe show code you've written so far, and any error
    > > > messages/tracebacks, to better indicate where you are stuck.

    >
    > > Thank you very much Steve,

    >
    > > I do have a good understanding of http and its headers rules, and of
    > > course I can work on that.
    > > On the other hand, I am new to python and SOAPpy toolkit and I dont
    > > have much of an experience working with ws in general.

    >
    > > When it comes of working with simple call to WS, everything is
    > > successfull; problems start cause I dont know how to use the toolkit
    > > to compose the http request. I should code it in the way that it
    > > connects to my proper proxy and it gets authenticated in the server
    > > exposing the service.

    >
    > > What I have is something like:
    > > from SOAPpy import WSDL

    >
    > > wsdl = 'http://myws?wsdl'
    > > my_http_proxy = '10.x.x.x:8080'
    > > proxy = WSDL.Proxy(wsdl, http_proxy=my_http_proxy)
    > > res = proxy.myService( myparam='...' )

    >
    > > What I get is that connection reaches timeout since the server doesnt
    > > see me coming from the right proxy.
    > > First problem, I can't see where I can put my proxy authentication
    > > username and password.
    > > Second, when I will be able to pass through the right proxy, I need to
    > > authenticate on the server via http through my credential.

    >
    > Have you looked at the URLopener class?


    At the end what I did is to use the authentication components offered
    by urllib2.
    Just I had to hand write the SOAP message outcoming, losing the chance
    to use SOAPpy.
    Anyway it seems to work this way,
    thanks again
     
    wdveloper, May 15, 2009
    #5
    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.

Share This Page