[Soap-Python] http-headers and soappy
Johann Spies
jspies at sun.ac.za
Tue Nov 9 13:35:49 CET 2010
I am new to Soap and will appreciate help on the following please.
Using the following code (up to the ====) I could successfully get a
session_id which should be included in further queries in the http
headers.
>From the documentation:
Header name: Cookie
Header value: [SID="the session identifier"]
What would be the most simple way to include the session_id (SID) as
header in further queries?
-----------------------------------------------------------------
import warning
warnings.simplefilter('ignore',DeprecationWarning)
from SOAPpy import HeaderHandler
from SOAPpy import WSDL
from SOAPpy import URLopener
url= 'http://search.isiknowledge.com/esti/wokmws/ws/WOKMWSAuthenticate?wsdl'
url1 = URLopener.URLopener(username='xy',passwd='xy')
server=WSDL.Proxy(url1.open(url))
import os
if os.environ.has_key('http_proxy'):
http_proxy_conf = os.environ['http_proxy'].replace('http://', '')
elif os.environ.has_key('HTTP_PROXY'):
http_proxy_conf = os.environ['HTTP_PROXY'].replace('http://', '')
else:
http_proxy_conf = 'proxy.sun.ac.za:3128'
server.soapproxy.http_proxy = http_proxy_conf
session_id = server.authenticate('http://auth.cxf.wokmws.thomsonreuters.com', 'authenticateResponse')
print "Session id: %s" % session_id
==============================
I have tried the following code (did not find much documentation that I
could understand) but I have to add another argument to HeaderHandler()
and I don't know what:
kopstukke = {'Name': 'Cookie', 'Value': 'SID = %s' % session_id}
hd = HeaderHandler(kopstukke)
hd.InteropTestHeader = session_id
hd._setMustUnderstand ('InteropTestHeader', 0)
hd._setActor ('InteropTestHeader','http://schemas.xmlsoap.org/soap/actor/next')
server = server._hd (hd)
respons = server.authenticate('http://auth.cxf.wokmws.thomsonreuters.com', 'closeSession')
print server.authenticate('http://auth.cxf.wokmws.thomsonreuters.com', 'closeSesisonResponse')
41 kopstukke = {'Name': 'Cookie', 'Value': 'SID = %s' % session_id}
---> 42 hd = HeaderHandler(kopstukke)
43 hd.InteropTestHeader = session_id
44 hd._setMustUnderstand ('InteropTestHeader', 0)
TypeError: __init__() takes exactly 3 arguments (2 given)
Regards
Johann
--
Johann Spies Telefoon: 021-808 4699
Databestuurder / Data manager
Sentrum vir Navorsing oor Evaluasie, Wetenskap en Tegnologie
Centre for Research on Evaluation, Science and Technology
Universiteit Stellenbosch.
"O death, where is thy sting? O grave, where is
thy victory?" 1 Corinthians 15:55
More information about the Soap
mailing list