def __call__(self, data, raw=False): e = data.to_xml(data, data.__class__.__name__) envelope = make_soap_envelope(e) body = et.tostring(envelope) methodName = '\"%s\"' % self.method httpHeaders = { 'Content-Length': len(body), 'Content-type': 'text/xml; charset="UTF-8"', 'Accept': ('application/soap+xml, application/dime, ' 'multipart/related, text/*'), 'User-Agent': 'Soaplib/1.0', 'SOAPAction': methodName, } scheme, host, path = split_url(self.host) if scheme == "http": conn = httplib.HTTPConnection(host) elif scheme == "https": conn = httplib.HTTPSConnection(host) else: raise RuntimeError("Unsupported URI connection scheme: %s" % scheme) conn.request("POST", path, body=body, headers=httpHeaders) response = conn.getresponse() raw_data = response.read() retval = et.fromstring(raw_data) pattern = '{http://schemas.xmlsoap.org/soap/envelope/}Body' node = retval.find(pattern).getchildren()[0] if raw: return node return objectify(node)
def __call__(self, data, raw=False): e = data.to_xml(data, data.__class__.__name__) envelope = make_soap_envelope(e) body = et.tostring(envelope) methodName = '\"%s\"' % self.method httpHeaders = { "Content-Length": len(body), "Content-type": 'text/xml; charset="UTF-8"', "Accept": "application/soap+xml, application/dime, multipart/related, text/*", 'User-Agent': 'Soaplib/1.0', 'SOAPAction': methodName } scheme, host, path = split_url(self.host) if scheme == "http": conn = httplib.HTTPConnection(host) elif scheme == "https": conn = httplib.HTTPSConnection(host) else: raise RuntimeError("Unsupported URI connection scheme: %s" % scheme) conn.request("POST", path, body=body, headers=httpHeaders) response = conn.getresponse() raw_data = response.read() retval = et.fromstring(raw_data) d = retval.find( '{http://schemas.xmlsoap.org/soap/envelope/}Body').getchildren()[0] if raw: return d return objectify(d)
def make_service_client(url, impl): scheme, host, path = split_url(url) return ServiceClient(host, path, impl, scheme)
def make_service_client(url,impl, certfile = None, keyfile = None): scheme,host,path = split_url(url) return ServiceClient(host,path,impl, scheme, certfile = certfile, keyfile = keyfile)
def make_service_client(url,impl): try: scheme,host,path = split_url(url) except Exception, err: raise Exception ("Endpoint url '%s' is not processed!"%url)