[Python] python实现简单的soap客户端 →→→→→进入此内容的聊天室

来自 , 2020-09-01, 写在 Python, 查看 174 次.
URL http://www.code666.cn/view/ac9815be
  1. # $Id: testquote.py 2924 2006-11-19 22:24:22Z fredrik $
  2. # delayed stock quote demo (www.xmethods.com)
  3.  
  4. from elementsoap.ElementSOAP import *
  5.  
  6. class QuoteService(SoapService):
  7.     url = "http://66.28.98.121:9090/soap"   # Put webservice URL here.
  8.     def getQuote(self, symbol):
  9.         action = "urn:xmethods-delayed-quotes#getQuote"
  10.         request = SoapRequest("{urn:xmethods-delayed-quotes}getQuote")  # Create the SOAP request
  11.         SoapElement(request, "symbol", "string", symbol)                # Add parameters
  12.         response = self.call(action, request)                           # Call webservice
  13.         return float(response.findtext("Result"))                       # Parse the answer and return it
  14.  
  15. q = QuoteService()
  16. print "MSFT", q.getQuote("MSFT")
  17. print "LNUX", q.getQuote("LNUX")
  18. #//python/1876

回复 "python实现简单的soap客户端"

这儿你可以回复上面这条便签

captcha