如何在Python中显示ZSI.ServiceProxy的出入SOAP消息?
如何在调用Web服务的方法时,显示由ZSI.ServiceProxy生成的SOAP消息和来自Web服务的响应?
1 个回答
3
这里有一些关于ServiceProxy类的文档。这个类的构造函数接受一个叫做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()