2012-02-24 53 views
0
from suds import WebFault 
from suds.client import Client 
from cookielib import Cookie 

import logging 
logging.basicConfig(level=logging.INFO) 
logging.getLogger('suds.transport').setLevel(logging.DEBUG) 

client = Client(url) 
loginResult = client.service.Login(username, password) 
print "==========================================" 
print client.options.transport.cookiejar 

如何從HTTP頭

DEBUG:suds.transport.http:sending: 
URL:http://127.0.0.1:34014 
HEADERS: {'SOAPAction': u'""', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': u'""'} 

DEBUG:suds.transport.http:received: 

CODE: 200 

HEADERS: { 
    'set-cookie': 'srv=869aa1577003769cbff7962d77641c4ae9134ac4;Domain=...;Path=/;Version=1;Max-Age=3600', 
    'content-length': '440', 
    'content-type': 'text/xml; charset=utf-8', 
    'connection': 'close', 
    'server': 'soap/1.9' 
} 

========================================== 

    <cookielib.CookieJar[]> 

========================================== 
None 
+0

您爲什麼認爲應該有任何cookie? – 2012-02-24 10:03:22

+0

'set-cookie':'srv = 869aa1577003769cbff7962d77641c4ae9134ac4 - 不是Cookie?如何獲得srv的價值? – Azimuth 2012-02-24 10:48:06

回答

0

得到的cookie如果client.options.transport.cookiejar這意味着cookielib不能從響應中的cookie。您應該看看Cookielib中的cookie驗證

+0

它是如何做的? – Azimuth 2012-02-24 11:38:56