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


Python SOAPProxy._ns方法代码示例

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


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

示例1: SOAPProxy

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import _ns [as 别名]
   proxy = None

SoapEndpointURL	   = 'http://www22.brinkster.com/prasads/BreakingNewsService.asmx?WSDL'

MethodNamespaceURI = 'http://tempuri.org/'

# Three ways to do namespaces, force it at the server level

server = SOAPProxy(SoapEndpointURL, namespace = MethodNamespaceURI,
                   soapaction='http://tempuri.org/GetCNNNews', encoding = None,
                   http_proxy=proxy)
print "[server level CNN News call]" 
print server.GetCNNNews()

# Do it inline ala SOAP::LITE, also specify the actually ns (namespace) and
# sa (soapaction)

server = SOAPProxy(SoapEndpointURL, encoding = None)
print "[inline CNNNews call]" 
print server._ns('ns1',
    MethodNamespaceURI)._sa('http://tempuri.org/GetCNNNews').GetCNNNews()

# Create an instance of your server with specific namespace and then use
# inline soapactions for each call

dq = server._ns(MethodNamespaceURI)
print "[namespaced CNNNews call]" 
print dq._sa('http://tempuri.org/GetCNNNews').GetCNNNews()
print "[namespaced CBSNews call]"
print dq._sa('http://tempuri.org/GetCBSNews').GetCBSNews()
开发者ID:smalllark,项目名称:Soappy,代码行数:32,代码来源:newsTest.py

示例2: SOAPProxy

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import _ns [as 别名]
#!/usr/bin/env python

ident = '$Id: weatherTest.py,v 1.4 2003/05/21 14:52:37 warnes Exp $'

import os, re
import sys
sys.path.insert(1, "..")

from SOAPpy import SOAPProxy

# Check for a web proxy definition in environment
try:
   proxy_url=os.environ['http_proxy']
   phost, pport = re.search('http://([^:]+):([0-9]+)', proxy_url).group(1,2)
   proxy = "%s:%s" % (phost, pport)
except:
   proxy = None

SoapEndpointURL	= 'http://services.xmethods.net:80/soap/servlet/rpcrouter'
MethodNamespaceURI = 'urn:xmethods-Temperature'

# Do it inline ala SOAP::LITE, also specify the actually ns

server = SOAPProxy(SoapEndpointURL, http_proxy=proxy)
print "inline", server._ns('ns1', MethodNamespaceURI).getTemp(zipcode='94063')
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:27,代码来源:weatherTest.py

示例3: Copyright

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import _ns [as 别名]
#!/usr/bin/env python

# Copyright (c) 2001 actzero, inc. All rights reserved.
ident = '$Id: translateTest.py,v 1.5 2003/05/21 14:52:37 warnes Exp $'

import os, re
import sys
sys.path.insert(1, "..")

from SOAPpy import SOAPProxy

# Check for a web proxy definition in environment
try:
   proxy_url=os.environ['http_proxy']
   phost, pport = re.search('http://([^:]+):([0-9]+)', proxy_url).group(1,2)
   proxy = "%s:%s" % (phost, pport)
except:
   proxy = None

server = SOAPProxy("http://services.xmethods.com:80/perl/soaplite.cgi",
                   http_proxy=proxy)
babel = server._ns('urn:xmethodsBabelFish#BabelFish')

print babel.BabelFish(translationmode = "en_fr",
    sourcedata = "The quick brown fox did something or other")
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:27,代码来源:translateTest.py

示例4: __init__

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import _ns [as 别名]
class VMRC:
	""" Class to connect with the VMRC server """
	# define the namespace
	namespace = 'http://ws.vmrc.grycap.org/'
	server = None

	def __init__(self, url, user = None, passwd = None):
		if user == None:
			self.server = SOAPProxy(url)
		else:
			self.server = SOAPProxy(url, transport = HTTPHeaderTransport)
			self.server.transport.headers = {'Username' : user,
							 'Password' : passwd}

		# if you want to see the SOAP message exchanged
		# uncomment the two following lines
		#self.server.config.dumpSOAPOut = 1
		#self.server.config.dumpSOAPIn = 1
		#self.server.config.dumpHeadersOut = 1

	@staticmethod
	def _toRADLSystem(vmi):

		# Pass common features
		VMRC_RADL_MAP = {
			'hypervisor': ('virtual_system_type', str),
			'diskSize': ('disk.0.size', int),
			'arch': ('cpu.arch', str),
			'location': ('disk.0.image.url', str),
			'name': ('disk.0.image.name', str),
			'userLogin': ('disk.0.os.credentials.username', str),
			'userPassword': ('disk.0.os.credentials.password', str)
		}
		fs = [ Feature(VMRC_RADL_MAP[prop][0], "=", VMRC_RADL_MAP[prop][1](getattr(vmi, prop)))
		                               for prop in VMRC_RADL_MAP if hasattr(vmi, prop) and getattr(vmi, prop) ]
		fs.extend([ Feature("disk.0.os." + prop, "=", getattr(vmi.os, prop))
		                                       for prop in ['name', "flavour", "version"]])
		
		if not hasattr(vmi, 'applications'):
			return system("", fs)

		# vmi.applications can store the attributes of a single application
		# or can be a list of objects.
		if vmi.applications and isinstance(vmi.applications[0], str):
			apps = [vmi.applications]
		else:
			apps = vmi.applications

		for app in apps:
			OS_VMRC_RADL_PROPS = ["name", "version", "path"]
			fs.append(Feature("disk.0.applications", "contains", FeaturesApp(
				[ Feature(prop, "=", getattr(app, prop))
					for prop in OS_VMRC_RADL_PROPS ] +
				[ Feature("preinstalled", "=", "yes") ] )))
		return system("", fs)

	def list_vm(self):
		"""Get a list of all the VM registered in the catalog."""

		try:
			vmrc_res = self.server._ns(self.namespace).list()
		except Exception:
			return None

		if len(vmrc_res) > 0:
			if isinstance(vmrc_res, list):
				return [ VMRC._toRADLSystem(vmi) for vmi in vmrc_res ]
			else:
				return [ VMRC._toRADLSystem(vmrc_res) ]
		else:
			return []

	def search_vm(self, radl_system):
		"""
		Get a list of the most suitable VM according to the requirements
		expressed by the user.
			
		Args:

		- radl_system(system): system that VMRC will search compatible configurations.

		Return(None or list of system): available virtual machines
		"""

		# If an images is already set, VMRC service is not asked
		if radl_system.getValue("disk.0.image.url"):
			return []

		vmi_desc_str_val = VMRC._generateVMRC(radl_system.features).strip()
		try:
			vmrc_res = self.server._ns(self.namespace).search(vmiDescStr = vmi_desc_str_val)
		except Exception:
			return []

		if len(vmrc_res) > 0:
			if isinstance(vmrc_res, list):
				return [ VMRC._toRADLSystem(vmi) for vmi in vmrc_res ]
			else:
				return [ VMRC._toRADLSystem(vmrc_res) ]
		else:
#.........这里部分代码省略.........
开发者ID:lxhiguera,项目名称:im,代码行数:103,代码来源:VMRC.py

示例5: Copyright

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import _ns [as 别名]
#!/usr/bin/env python

# Copyright (c) 2001 actzero, inc. All rights reserved.
ident = '$Id: quoteTest.py,v 1.5 2003/12/18 06:31:50 warnes Exp $'

import os, re
import sys
sys.path.insert(1, "..")

from SOAPpy import SOAPProxy

# Three ways to do namespaces, force it at the server level

server = SOAPProxy("http://services.xmethods.com:9090/soap",
                        namespace = 'urn:xmethods-delayed-quotes')

print "IBM>>", server.getQuote(symbol = 'IBM')

# Do it inline ala SOAP::LITE, also specify the actually ns

server = SOAPProxy("http://services.xmethods.com:9090/soap")
print "IBM>>", server._ns('ns1',
    'urn:xmethods-delayed-quotes').getQuote(symbol = 'IBM')

# Create a namespaced version of your server

dq = server._ns('urn:xmethods-delayed-quotes')
print "IBM>>", dq.getQuote(symbol='IBM')
print "ORCL>>", dq.getQuote(symbol='ORCL')
print "INTC>>", dq.getQuote(symbol='INTC')
开发者ID:nedmax,项目名称:SOAPpy,代码行数:32,代码来源:quoteTest.py

示例6: SOAPProxy

# 需要导入模块: from SOAPpy import SOAPProxy [as 别名]
# 或者: from SOAPpy.SOAPProxy import _ns [as 别名]
sys.path.insert(1, "..")

from SOAPpy import SOAPProxy

# Check for a web proxy definition in environment
try:
    proxy_url = os.environ["http_proxy"]
    phost, pport = re.search("http://([^:]+):([0-9]+)", proxy_url).group(1, 2)
    proxy = "%s:%s" % (phost, pport)
except:
    proxy = None

# Three ways to do namespaces, force it at the server level

server = SOAPProxy("http://services.xmethods.com:9090/soap", namespace="urn:xmethods-delayed-quotes", http_proxy=proxy)

print "IBM>>", server.getQuote(symbol="IBM")

# Do it inline ala SOAP::LITE, also specify the actually ns

server = SOAPProxy("http://services.xmethods.com:9090/soap", http_proxy=proxy)
print "IBM>>", server._ns("ns1", "urn:xmethods-delayed-quotes").getQuote(symbol="IBM")

# Create a namespaced version of your server

dq = server._ns("urn:xmethods-delayed-quotes")
print "IBM>>", dq.getQuote(symbol="IBM")
print "ORCL>>", dq.getQuote(symbol="ORCL")
print "INTC>>", dq.getQuote(symbol="INTC")
开发者ID:sigma,项目名称:pywebsvcs,代码行数:31,代码来源:quoteTest.py


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