Exemplo n.º 1
0
import base64
class HTTPSudsPreprocessor(BaseHandler):
    def http_request(self, req):
        req.add_header('Content-Type', 'text/xml; charset=utf-8')
        req.add_header('WWW-Authenticate', 'Basic realm="Control Panel"')
        #The below lines are to encode the credentials automatically
        cred=userid+':'+passwd
        if cred!=None:
            enc_cred=base64.encodestring(cred)
            req.add_header('Authorization', 'Basic '+ enc_cred.replace('\012',''))
        return req
    https_request = http_request

http = HttpTransport()
opener = build_opener(HTTPSudsPreprocessor)
http.urlopener = opener


######################### For  Basic Authentication #################################
client = Client(url, location=url.replace('?wsdl',''), transport=http, cache=None, timeout=90, faults=False, retxml=True)
#####################################################################################


def SendSOAPMessage(code, request):
	##LogInput('core_send.py >> Looking for  %s' % request.get('MessageCode'))

    if code == "NpRequest":
    
        try:
			#LogInput('Inside try statement Sending NpRequest!! %s',str(request))