如何输出 SUD 正在生成/接收的内容?
我有以下代码:
from suds.client import Client
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
SB_PRIVATE_ACCESS = {"PATH":"https://thisurl.com:443/services/",}
client = Client(SB_PRIVATE_ACCESS['PATH'])
print client
但我收到 500 个错误。我正在尝试将通过 SUD 生成和接收的 XML 发送给 wsdl 开发人员,但我不知道如何输出它?我一直在查看 SUD 的文档,但似乎找不到它:/有人知道如何输出发送和接收的原始 xml 吗?
I have the following code:
from suds.client import Client
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)
logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)
SB_PRIVATE_ACCESS = {"PATH":"https://thisurl.com:443/services/",}
client = Client(SB_PRIVATE_ACCESS['PATH'])
print client
but I am getting 500 errors. I am trying to send what XML is being generated and received through SUDs, to the wsdl developer, but I can't figure how to output it? I have been looking in the documentation of SUDs, but can't seem to find it :/ Does anyone know how to output the raw xml that is sent and received?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
SUDS 提供了一些方便的方法来做到这一点:
这些应该可以满足您的需要。我用它们来记录错误。
Client 类的 Client 类的 API 文档 应该包含您需要的任何额外信息。
SUDS provides some convenience methods to do just that:
These should provide you with what you need. I use them for error logging.
The API doc for Client class should have any extra info you need.
您可以使用 MessagePlugin 来执行此操作(这适用于较新的 Jurko 分支,其中 last_sent 和 last_received 已被删除)
You can use the MessagePlugin to do this (this will work on the newer Jurko fork where last_sent and last_received have been removed)
Suds 支持内部日志记录,就像您一直在做的那样。
我像你一样设置信息级别:
有时我还需要覆盖根记录器日志记录级别,具体取决于 Suds 调用下使用的框架(Django、Plone)。如果根记录器具有更高的日志记录阈值,则日志消息可能永远不会出现(不确定记录器层次结构应该如何发展)。下面是如何覆盖的示例:
Suds supports internal logging, as you have been doing.
I am setting info levels like you:
And I also sometimes need to override the root logger logging level, depending on the framework being used under Suds calls (Django, Plone). If the root logger has a higher logging threshold, log messaegs may never appear (not sure how logger hierarchies should go). Below is an example how to override:
要仅获取生成的消息,这也有效:
To get only the generated message this also works:
尝试更改
为
try changing
to
如果您想减少 jurko-suds 的日志记录
If you want to reduce logging by jurko-suds
我在使用 bingads API 时遇到了这个问题,值得注意的是,顺序很重要,我必须导入日志记录,然后导入 suds 启动日志记录,然后导入 bingads,任何其他顺序,suds 的日志中没有输出任何内容。
因此,检查您的导入订单,并移动您的日志记录语句,它可能会解决您的问题。
I have hit this problem working with the bingads API, worth noting the order is important I had to import logging then import suds start the logging then import bingads, any other order and nothing was output in the logs from suds.
So check your import order, and move your logging statements and it may fix your issue.