2012-04-03 1 views

답변

7

해야 할 것보다 더 많은 노력이 필요합니다.

여기 0.3.9 버전의 제스처가 있습니다. 사용중인 전송 클래스를 서브 클래스 화하고 전송 클래스의 마지막 수신 된 헤더를 저장하는 send 메서드를 래핑해야했습니다.

import logging 
logging.basicConfig(level=logging.INFO) 
#logging.getLogger('suds.client').setLevel(logging.DEBUG) 
#logging.getLogger('suds.transport').setLevel(logging.DEBUG) 
#logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) 
#logging.getLogger('suds.wsdl').setLevel(logging.DEBUG) 

from suds.client import Client 
from suds.xsd.doctor import ImportDoctor, Import 
from suds.transport.https import HttpAuthenticated 

class MyTransport(HttpAuthenticated): 
    def __init__(self,*args,**kwargs): 
     HttpAuthenticated.__init__(self, *args, **kwargs) 
     self.last_headers = None 

    def send(self,request): 
     result = HttpAuthenticated.send(self, request) 
     self.last_headers = result.headers 
     return result 

doctor = ImportDoctor(Import('http://schemas.xmlsoap.org/soap/encoding/')) 
svc_url = 'https://server/Service?wsdl' 
svc_user = 'username' 
svc_pass = 'password' 

client = Client(svc_url,doctor=doctor,transport=MyTransport()) 
# For some reason I can't be bothered to investigate, setting the username and password in 
# client kwargs doesn't pass them to the custom transport: 
client.set_options(location=svc_url.partition('?')[0],username=svc_user,password=svc_pass) 
# call a method 
client.service.SomeMethod() 
# look at headers 
client.options.transport.last_headers 
+0

대단히 감사합니다. 나는 그것이 명백하지 않았기 때문에 기쁘다. – PriceChild