SUDS 自定义标题 [英] SUDS Custom Header

查看:69
本文介绍了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 自定义标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆