如何在 Python(版本 2.1)中显示 ZSI.ServiceProxy 的传出和传入 SOAP 消息?

发布于 2024-09-18 23:05:00 字数 351 浏览 5 评论 0原文

几个月前,我问了同样的问题,但在旧版本的 ZSI 的背景下(如何在 Python 中显示 ZSI.ServiceProxy 的传出和传入 SOAP 消息?)。现在,在新版本的 ZSI 2.1 中没有 tacefile 参数)。我试图找到新版本的文档,但失败了。 有人知道如何显示 ZSI 2.1 生成和接收的 SOAP 消息吗? 提前谢谢您:-)

Couple months ago I have asked the same question but in the context of older version of ZSI (How to display outcoming and incoming SOAP message for ZSI.ServiceProxy in Python?). Now, in the new version of ZSI 2.1 there is no tacefile parameter). I tried to find a documentation for the new version but I faild. Does anyone know how to display the SOAP messages generated and received by ZSI 2.1? Thank you in advance :-)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

圈圈圆圆圈圈 2024-09-25 23:05:00

为了调试,我找到了使用wireshark来跟踪TCP包的干扰较少的解决方案。它看起来像这样:

alt text

For debugging I have found less interfering solution using wireshark to trace the TCP packages. It looks like that:

alt text

隔岸观火 2024-09-25 23:05:00

我也有同样的问题。我的解决方法是修改ZSI附带的dispatch.py​​文件。

我为我的应用程序创建了一个日志记录函数 (logmessage),它将 SOAP 消息存储到数据库中,然后在必要时添加该函数。但我不记得我使用的 ZSI 版本。不过,您应该能够在代码中轻松找到这些函数。 进行其他编辑以来,我有大约 L 数

自从我在站点包目录中的 Dispatch.py​​ 文件中

L156 - 记录 SOAP 响应

def _Dispatch(tons-of-args, **kw):
     #several lines of code edited here#
     #several lines of code edited here#
     #several lines of code edited here#

     sw = SoapWriter(nsdict=nsdict)
     sw.serialize(result, tc)
     logmessage( str(sw), 1, kw['request'].get_remote_host() ) #LOGGING HERE

L168 - 记录 SOAP 错误

def _ModPythonSendFault(f, **kw):
    logmessage( str(f.AsSOAP()), 1, kw['request'].get_remote_host() )  #LOGGING ADDED HERE
    _ModPythonSendXML(f.AsSOAP(), 500, **kw)

L277 - 记录请求

def AsHandler(request=None, modules=None, **kw):
    '''Dispatch from within ModPython.'''
    a = request.read(-1)
    logmessage( a, 0, request.get_remote_host() ) #LOGGING ADDED HERE
    ps = ParsedSoap(a)
    kw['request'] = request
    _Dispatch(ps, modules, _ModPythonSendXML, _ModPythonSendFault, **kw)

I had this same problem. My workaround was to modify the dispatch.py file that comes with ZSI.

I created a logging function (logmessage) for my app that would store SOAP messages into a database and then added that function where necessary. I do not recall the ZSI version I was using however. You should be able to find these functions pretty easily in the code though. I ave approximate L numbers since i made other edits

in Dispatch.py file in your site-packages directory

L156 - logs SOAP responses

def _Dispatch(tons-of-args, **kw):
     #several lines of code edited here#
     #several lines of code edited here#
     #several lines of code edited here#

     sw = SoapWriter(nsdict=nsdict)
     sw.serialize(result, tc)
     logmessage( str(sw), 1, kw['request'].get_remote_host() ) #LOGGING HERE

L168 - logs SOAP errors

def _ModPythonSendFault(f, **kw):
    logmessage( str(f.AsSOAP()), 1, kw['request'].get_remote_host() )  #LOGGING ADDED HERE
    _ModPythonSendXML(f.AsSOAP(), 500, **kw)

L277 - logs requests

def AsHandler(request=None, modules=None, **kw):
    '''Dispatch from within ModPython.'''
    a = request.read(-1)
    logmessage( a, 0, request.get_remote_host() ) #LOGGING ADDED HERE
    ps = ParsedSoap(a)
    kw['request'] = request
    _Dispatch(ps, modules, _ModPythonSendXML, _ModPythonSendFault, **kw)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文