如何在Python中显示ZSI.ServiceProxy的传出和传入SOAP消息?

时间:2009-09-30 09:33:13

标签: python web-services zsi

如何在调用Web Service方法时显示由ZSI.ServiceProxy生成的SOAP消息和Web Service的响应?

1 个答案:

答案 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()