pythonweb-serviceszsi

How to display outcoming and incoming SOAP message for ZSI.ServiceProxy in Python?


How to display a SOAP message generated by ZSI.ServiceProxy and a respond from a Web Service when a Web Service method is invoked?


Solution

  • Here is some documentation on the ServiceProxy class. The constructor accepts a tracefile argument which can be any object with a write method, so this looks like what you are after. Modifying the example from the documentation:

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