python实现简单的soap客户端

2018-07-20    来源:open-open

容器云强势上线!快速搭建集群,上万Linux镜像随意使用
# $Id: testquote.py 2924 2006-11-19 22:24:22Z fredrik $
# delayed stock quote demo (www.xmethods.com)
 
from elementsoap.ElementSOAP import *
 
class QuoteService(SoapService):
    url = "http://66.28.98.121:9090/soap"   # Put webservice URL here.
    def getQuote(self, symbol):
        action = "urn:xmethods-delayed-quotes#getQuote"
        request = SoapRequest("{urn:xmethods-delayed-quotes}getQuote")  # Create the SOAP request
        SoapElement(request, "symbol", "string", symbol)                # Add parameters
        response = self.call(action, request)                           # Call webservice
        return float(response.findtext("Result"))                       # Parse the answer and return it
 
q = QuoteService()
print "MSFT", q.getQuote("MSFT")
print "LNUX", q.getQuote("LNUX")

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。

上一篇:python模拟Get请求保存网易歌曲的url

下一篇:python读取ini配置文件