[Fedora-suds-list] HttpAuthenticated for WSDL open

Ryan Schroeder ryanitus at gmail.com
Mon Dec 21 23:03:49 UTC 2009


Here's the open function for HttpAuthenticated.

class HttpAuthenticated(HttpTransport):
    """
    Provides basic http authentication for servers that don't follow
    the specified challenge / response model.  This implementation
    appends the I{Authorization} http header with base64 encoded
    credentials on every http request.
    """
    def open(self, request):
        credentials = self.credentials()
        theurl = request.url
        username = credentials[0]
        password = credentials[1]
        passman = u2.HTTPPasswordMgrWithDefaultRealm()
        passman.add_password(None, theurl, username, password)
        authhandler = u2.HTTPBasicAuthHandler(passman)
        opener = u2.build_opener(authhandler)
        u2.install_opener(opener)
        return HttpTransport.open(self, request)




On Mon, Dec 21, 2009 at 2:16 PM, Ryan Schroeder <ryanitus at gmail.com> wrote:

> Hello,
>
> I have a server that requires basic HTTP authentication to download the
> WSDL file.  I tried setting the transport to HTTPAuthenticated, but it looks
> like the Client doesn't apply the options.transport when opening the url.
>
> Here's the snippet I'm referring to from client.py:
>
>     def __init__(self, url, **kwargs):
>         """
>         @param url: The URL for the WSDL.
>         @type url: str
>         @param kwargs: keyword arguments.
>         @see: L{Options}
>         """
>         options = Options()
>         options.transport = HttpAuthenticated()
>         self.options = options
>         options.cache = FileCache(days=1)
>         self.set_options(**kwargs)
>         self.wsdl = Definitions(url, options)           <--------------
> shouldn't this be self.options?
>
>
> I tried making this change, but also ran into the fact that the
> HttpAuthenticated class does not override the open method using a provided
> username and password.  The basic HttpTransport open method is called
> instead.
>
> Regards,
>
> Ryan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/suds/attachments/20091221/c88ca8f4/attachment.html 


More information about the suds mailing list