当前位置: 首页>>代码示例>>Python>>正文


Python Address.checkResponse方法代码示例

本文整理汇总了Python中ZSI.address.Address.checkResponse方法的典型用法代码示例。如果您正苦于以下问题:Python Address.checkResponse方法的具体用法?Python Address.checkResponse怎么用?Python Address.checkResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZSI.address.Address的用法示例。


在下文中一共展示了Address.checkResponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: binding

# 需要导入模块: from ZSI.address import Address [as 别名]
# 或者: from ZSI.address.Address import checkResponse [as 别名]

#.........这里部分代码省略.........
		trace = self.trace
		while 1:
			response = self.h.getresponse()
			self.reply_code, self.reply_msg, self.reply_headers, self.data = \
				response.status, response.reason, response.msg, response.read()
			if trace:
				print >>trace, "_" * 33, time.ctime(time.time()), "RESPONSE:"
				for i in (self.reply_code, self.reply_msg,):
					print >>trace, str(i)
				print >>trace, "-------"
				print >>trace, str(self.reply_headers)
				print >>trace, self.data
			saved = None
			for d in response.msg.getallmatchingheaders('set-cookie'):
				if d[0] in [ ' ', '\t' ]:
					saved += d.strip()
				else:
					if saved: self.cookies.load(saved)
					saved = d.strip()
			if saved: self.cookies.load(saved)
			if response.status == 401:
				if not callable(self.http_callbacks.get(response.status,None)):
					raise RuntimeError, 'HTTP Digest Authorization Failed'
				self.http_callbacks[response.status](response)
				continue
			if response.status != 100: break

			# The httplib doesn't understand the HTTP continuation header.
			# Horrible internals hack to patch things up.
			self.h._HTTPConnection__state = httplib._CS_REQ_SENT
			self.h._HTTPConnection__response = None
		return self.data

	def IsSOAP(self):
		if self.ps: return 1
		self.ReceiveRaw()
		mimetype = self.reply_headers.type
		return mimetype == 'text/xml'

	def ReceiveSOAP(self, readerclass=None, **kw):
		'''Get back a SOAP message.
		'''
		if self.ps: return self.ps
		print "\n--------"
		print self.data
		print "--------"		
		if not self.IsSOAP():
			raise TypeError(
				'Response is "%s", not "text/xml"' % self.reply_headers.type)
		if len(self.data) == 0:
			raise TypeError('Received empty response')

		self.ps = ParsedSoap(self.data, 
						readerclass=readerclass or self.readerclass, 
						encodingStyle=kw.get('encodingStyle'))

		if self.sig_handler is not None:
			self.sig_handler.verify(self.ps)

		return self.ps

	def IsAFault(self):
		'''Get a SOAP message, see if it has a fault.
		'''
		self.ReceiveSOAP()
		return self.ps.IsAFault()

	def ReceiveFault(self, **kw):
		'''Parse incoming message as a fault. Raise TypeError if no
		fault found.
		'''
		self.ReceiveSOAP(**kw)
		if not self.ps.IsAFault():
			raise TypeError("Expected SOAP Fault not found")
		return FaultFromFaultMessage(self.ps)

	def Receive(self, replytype, **kw):
		'''Parse message, create Python object.

		KeyWord data:
			faults	 -- list of WSDL operation.fault typecodes
			wsaction -- If using WS-Address, must specify Action value we expect to
				receive.
		'''
		self.ReceiveSOAP(**kw)
		if self.ps.IsAFault():
			msg = FaultFromFaultMessage(self.ps)
			raise FaultException(msg)

		tc = replytype
		if hasattr(replytype, 'typecode'):
			tc = replytype.typecode

		reply = self.ps.Parse(tc)
		if self.address is not None:
			self.address.checkResponse(self.ps, kw.get('wsaction'))
		return reply

	def __repr__(self):
		return "<%s instance %s>" % (self.__class__.__name__, _get_idstr(self))
开发者ID:japina,项目名称:ZSI-hacking,代码行数:104,代码来源:client.py


注:本文中的ZSI.address.Address.checkResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。