Re: [Rslib-talk] Basic auth, location, and WSDL questions
Status: Alpha
Brought to you by:
gweis
From: Gerhard W. <ger...@gm...> - 2009-02-09 12:18:11
|
Hello Matt, Thanks for your comments. On 09/02/2009, at 6:42 AM, Matt C wrote: > Thanks for writing the package - it looks very good and it's > encouraging to see some life in the Python SOAP world. I've got a > few questions (hopefully these will help the documentation effort at > some point): > > 1) Does anyone have an example of a call with HTTP basic auth? The > project I am working on requires it. > HTTP basic auth can be handled with standard python urllib2 handlers. The package 'rsl' contains a basic auth handler. However you might want to customise it to your needs. (see rsl.misc.http). I.e. have a look at 'def installopener'. This method installs the default urllib2.HTTPBasicAuthHandler. The class 'AskPasswordHandler' in this module asks for a password at the command line. So you migth provide your own PasswordHandler here. > 2) Is there a way for me to load a WSDL from disk as opposed to > calling it remotely? We plan to have a bunch of WSDLs in a local > directory that you can load and point to various remote systems > which all support the same methods. > The easiest way to load WSDLs from disk is to use the 'file:' url scheme instead of e.g. 'http://'. If you need more control, have a look at loadWSDL in package rsl.wsdl.wsdl. > 3) From what I can see it looks like rsl pulls the end point > information from the WSDL. I'd like to be able to set the hostname > of a remote service when I instantiate a proxy object (similar to > ZSI's ServiceProxy class). I've tried setting the location attribute > after building the proxy but this doesn't seem to work. > This is definitely possible, but you need to manipulate the end point url in the WSDL-File itself or you can do it on the instantiated WSDL. However, there is not enough API available on the WSDL instance, so you have to do this manually. Probably the easisest way is to do the following: portlist = wsdl._getportlist(namespace=NS_SOAP) # _getportlist supports also servicename and portname parameters; servicename is a fully qualified name. # for each port in portlist you can update the location attribute portlist[0].location = 'newurl' Proxies created after that should have the new location attribute as endpoint address. (If it does not work, please let me know, and I'll digg more into it.) If you want to change the endpoint address on the proxy you have to do it for each single operation. I guess the whole point 3 needs a some more attention in future development. :) > 4) Are there any plans to generate classes from WSDLs? > Nothing concrete for now. The plan is, to create nice dynamic modules for xml-schema and wsdl. After these modules are finished, it should not be a big deal to write some kind of code-generator (dynamic or static.). The current plan for xml-schema is to provide a pluggable mechanism to use custom classes instead of the standard python data type for de/ serialisation. This mechanism will likely use plenty of code and ideas from the zope component architecture in the background. Another design goal is, to create a nice component architecture, were all components are replaceable/adaptable. This should make it possible to 'plug' a class generator into the whole component-architecture if needed. (Or even write an additional script which uses the available components and generates some code just like wsdl2py). > Many thanks! > > Matt > I hope this helps, If you have any further questions, issues, suggestions, I am happy to help out. cheers Gerhard |