添加 CustomTransport 时忽略 SUDS headers

SUDS headers ignored when adding CustomTransport

我正在尝试使用带有 subs 的 Web 服务,我想在其中忽略证书检查,因为我使用的是自签名证书。

我在这里找到了执行此操作的方法:

CustomTransport class 的复制与答案中的完全相同。

但我收到错误消息: 异常:(415, u"Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'.")

即使我在 headers 中将内容类型设置为 soap:

aHeader = {
    "Content-Type" : 'application/soap+xml; charset=UTF-8',
    "SOAPAction": "",
}

client = Client(wsdl, transport=CustomTransport(), headers=aHeader)

我找不到发生这种情况的原因,有人可以帮忙吗?

它因为 CustomTransport 而被忽略,所以要完成这项工作,您需要将 headers 放在 customtransport 中,如下所示:

client = Client(wsdl, transport=CustomTransport(headers=aHeader))