如何在调用Web Service方法时显示由ZSI.ServiceProxy生成的SOAP消息和Web Service的响应?
答案 0 :(得分:2)
这是ServiceProxy类的一些documentation。构造函数接受tracefile
参数,该参数可以是具有write
方法的任何对象,因此这看起来就像您所追求的那样。修改文档中的示例:
from ZSI import ServiceProxy
import BabelTypes
import sys
dbgfile = open('dbgfile', 'w') # to log trace to a file, or
dbgfile = sys.stdout # to log trace to stdout
service = ServiceProxy('http://www.xmethods.net/sd/BabelFishService.wsdl',
tracefile=dbgfile,
typesmodule=BabelTypes)
value = service.BabelFish('en_de', 'This is a test!')
dbgfile.close()