當前位置: 首頁>>代碼示例>>Python>>正文


Python SoapWriter.serialize_header方法代碼示例

本文整理匯總了Python中ZSI.SoapWriter.serialize_header方法的典型用法代碼示例。如果您正苦於以下問題:Python SoapWriter.serialize_header方法的具體用法?Python SoapWriter.serialize_header怎麽用?Python SoapWriter.serialize_header使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ZSI.SoapWriter的用法示例。


在下文中一共展示了SoapWriter.serialize_header方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: AsSOAP

# 需要導入模塊: from ZSI import SoapWriter [as 別名]
# 或者: from ZSI.SoapWriter import serialize_header [as 別名]
    def AsSOAP(self, **kw):

        header = self.DataForSOAPHeader() 
        sw = SoapWriter(**kw)
        self.serialize(sw)
        if header is not None:
            sw.serialize_header(header, header.typecode, typed=False)
        return str(sw)
開發者ID:eveningwear,項目名稱:aqua-release,代碼行數:10,代碼來源:fault.py

示例2: Send

# 需要導入模塊: from ZSI import SoapWriter [as 別名]
# 或者: from ZSI.SoapWriter import serialize_header [as 別名]
	def Send(self, url, opname, obj, nsdict={}, soapaction=None, wsaction=None, 
			 endPointReference=None, soapheaders=(), **kw):
		'''Send a message.	If url is None, use the value from the
		constructor (else error). obj is the object (data) to send.
		Data may be described with a requesttypecode keyword, the default 
		is the class's typecode (if there is one), else Any.

		Try to serialize as a Struct, if this is not possible serialize an Array.  If 
		data is a sequence of built-in python data types, it will be serialized as an
		Array, unless requesttypecode is specified.

		arguments:
			url -- 
			opname -- struct wrapper
			obj -- python instance

		key word arguments:
			nsdict -- 
			soapaction --
			wsaction -- WS-Address Action, goes in SOAP Header.
			endPointReference --  set by calling party, must be an 
				EndPointReference type instance.
			soapheaders -- list of pyobj, typically w/typecode attribute.
				serialized in the SOAP:Header.
			requesttypecode -- 

		'''
		url = url or self.url
		endPointReference = endPointReference or self.endPointReference

		# Serialize the object.
		d = {}
		d.update(self.nsdict)
		d.update(nsdict)

		sw = SoapWriter(nsdict=d, header=True, outputclass=self.writerclass, 
				 encodingStyle=kw.get('encodingStyle'),)
		
		requesttypecode = kw.get('requesttypecode')
		if kw.has_key('_args'): #NamedParamBinding
			tc = requesttypecode or TC.Any(pname=opname, aslist=False)
			sw.serialize(kw['_args'], tc)
		elif not requesttypecode:
			tc = getattr(obj, 'typecode', None) or TC.Any(pname=opname, aslist=False)
			try:
				if type(obj) in _seqtypes:
					obj = dict(map(lambda i: (i.typecode.pname,i), obj))
			except AttributeError:
				# can't do anything but serialize this in a SOAP:Array
				tc = TC.Any(pname=opname, aslist=True)
			else:
				tc = TC.Any(pname=opname, aslist=False)

			sw.serialize(obj, tc)
		else:
			sw.serialize(obj, requesttypecode)
			
		for i in soapheaders:
		   sw.serialize_header(i) 
			
		# 
		# Determine the SOAP auth element.	SOAP:Header element
		if self.auth_style & AUTH.zsibasic:
			sw.serialize_header(_AuthHeader(self.auth_user, self.auth_pass),
				_AuthHeader.typecode)

		# 
		# Serialize WS-Address
		if self.wsAddressURI is not None:
			if self.soapaction and wsaction.strip('\'"') != self.soapaction:
				raise WSActionException, 'soapAction(%s) and WS-Action(%s) must match'\
					%(self.soapaction,wsaction)

			self.address = Address(url, self.wsAddressURI)
			self.address.setRequest(endPointReference, wsaction)
			self.address.serialize(sw)

		# 
		# WS-Security Signature Handler
		if self.sig_handler is not None:
			self.sig_handler.sign(sw)

		scheme,netloc,path,nil,nil,nil = urlparse.urlparse(url)
		transport = self.transport
		if transport is None and url is not None:
			if scheme == 'https':
				transport = self.defaultHttpsTransport
			elif scheme == 'http':
				transport = self.defaultHttpTransport
			else:
				raise RuntimeError, 'must specify transport or url startswith https/http'

		# Send the request.
		if issubclass(transport, httplib.HTTPConnection) is False:
			raise TypeError, 'transport must be a HTTPConnection'

		soapdata = str(sw)
		self.h = transport(netloc, None, **self.transdict)
		self.h.connect()
		self.SendSOAPData(soapdata, url, soapaction, **kw)
開發者ID:japina,項目名稱:ZSI-hacking,代碼行數:102,代碼來源:client.py

示例3: Send

# 需要導入模塊: from ZSI import SoapWriter [as 別名]
# 或者: from ZSI.SoapWriter import serialize_header [as 別名]
    def Send(self, url, opname, obj, nsdict={}, soapaction=None, wsaction=None, 
             endPointReference=None, **kw):
        '''Send a message.  If url is None, use the value from the
        constructor (else error). obj is the object (data) to send.
        Data may be described with a requesttypecode keyword, or a
        requestclass keyword; default is the class's typecode (if
        there is one), else Any.

        Optional WS-Address Keywords
            wsaction -- WS-Address Action, goes in SOAP Header.
            endPointReference --  set by calling party, must be an 
                EndPointReference type instance.

        '''
        url = url or self.url
        # Get the TC for the obj.
        if kw.has_key('requesttypecode'):
            tc = kw['requesttypecode']
        elif kw.has_key('requestclass'):
            tc = kw['requestclass'].typecode
        elif type(obj) == types.InstanceType:
            tc = getattr(obj.__class__, 'typecode')
            if tc is None: tc = TC.Any(opname, aslist=1)
        else:
            tc = TC.Any(opname, aslist=1)

        endPointReference = endPointReference or self.endPointReference

        # Serialize the object.
        d = {}

        d.update(self.nsdict)
        d.update(nsdict)

        useWSAddress = self.wsAddressURI is not None
        sw = SoapWriter(nsdict=d, header=True, outputclass=self.writerclass, 
                 encodingStyle=kw.get('encodingStyle'),)
        if kw.has_key('_args'):
            sw.serialize(kw['_args'], tc)
        else:
            sw.serialize(obj, tc)

        # Determine the SOAP auth element.  SOAP:Header element
        if self.auth_style & AUTH.zsibasic:
            sw.serialize_header(_AuthHeader(self.auth_user, self.auth_pass),
                _AuthHeader.typecode)

        # Serialize WS-Address
        if useWSAddress is True:
            if self.soapaction and wsaction.strip('\'"') != self.soapaction:
                raise WSActionException, 'soapAction(%s) and WS-Action(%s) must match'\
                    %(self.soapaction,wsaction)
            self.address = Address(url, self.wsAddressURI)
            self.address.setRequest(endPointReference, wsaction)
            self.address.serialize(sw)

        # WS-Security Signature Handler
        if self.sig_handler is not None:
            self.sig_handler.sign(sw)
        soapdata = str(sw)

        scheme,netloc,path,nil,nil,nil = urlparse.urlparse(url)

        # self.transport httplib.HTTPConnection derived class set-up removed
        # from HERE - this now handled by urllib2.urlopen()
        self.SendSOAPData(soapdata, url, soapaction, **kw)
開發者ID:philipkershaw,項目名稱:ndg-security,代碼行數:68,代碼來源:VocabServerAPIService_client.py


注:本文中的ZSI.SoapWriter.serialize_header方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。