SUDS 自定义标题

编程入门 行业动态 更新时间:2024-10-12 05:50:46
本文介绍了SUDS 自定义标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是 Python 新手,我使用 suds 作为 wsdl 客户端.如何为此创建自定义请求标头.

I'm new to Python and I use suds for wsdl client. How can I create custom request header for this.

从 SOAP UI 获取 XML :

XML get from SOAP UI :

<soapenv:Header> <sbus:SBusContext message-tracking-id="?" correlation-id="?" entry-dtime="?" timestamp="?" entry-system="?" entry-system-principal="?" entry-url="?" priority="?"> <!--Optional:--> <sbus:Keys> <!--1 or more repetitions:--> <sbus:Key keyType="?" keyValDataType="string"> <sbus:KeyValue>?</sbus:KeyValue> </sbus:Key> </sbus:Keys> <!--Optional:--> <sbus:ExtContext>?</sbus:ExtContext> </sbus:SBusContext> </soapenv:Header>

推荐答案

EDIT -

我意识到您可能问的是 SOAP 标头,而不是 http 标头.如果是这样,请忽略我的回答.我的错.

I realized you're probably asking about a SOAP header, not an http header. If so, ignore my answer. My bad.

看这里:如何添加httpsuds 0.3.6 中的标题?

您可以在创建客户端时添加标题,如下所示:

You can add the header when creating the client like this:

client = suds.client.Client(url, headers={'key': 'value'})

或者在创建客户端之后,使用 set_options 像这样:

Or after the client is created, by using set_options like this:

client.set_options(headers={'key2': 'value'})

值得注意的是,不再维护原始的 suds 包(2010 年 9 月的最新版本).它缺少您可能需要的各种功能,例如 gzip 压缩(因此,如果您使用的是旧的 suds 包,请不要费心添加accept-encoding:gzip"标头).各种叉子如雨后春笋般涌现.我相信其中最活跃的是 suds-jurko.

Worth noting that the original suds package is no longer maintained (last release Sept 2010). It lacks various features you might want, like gzip compression (so don't bother adding an 'accept-encoding:gzip' header if you're using the old suds package). Various forks have sprung up. I believe the most active of them is suds-jurko.

更多推荐

SUDS 自定义标题

本文发布于:2023-10-30 07:22:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542165.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   标题   SUDS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!