本文介绍了通过 SUDS 发送 xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过 SUDS 使用 WSDL 发送我的手工构建 xml.我发现,我可以这样做:
I would like to send my hand build xml by SUDS using WSDL. I found, that I can do it like that:
xml = Raw("""
<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetAccountBalance>
<ns0:Document>
<myData>
something
</myData>
</ns0:Document>
</ns0:GetAccountBalance>
</ns1:Body>
</SOAP-ENV:Envelope>
""")
print client.service.GetAccountBalance(xml)
但是使用这种方法 SUDS 发送:
But using this method SUDS sends:
<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetAccountBalance>
<ns0:Document>
<SOAP-ENV:Envelope xmlns:ns0="urn:ca:std:cdc:tech:xsd:cdc.001.01" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns0:GetAccountBalance>
<ns0:Document>
<myData>
something
</myData>
</ns0:Document>
</ns0:GetAccountBalance>
</ns1:Body>
</SOAP-ENV:Envelope>
</ns0:Document>
</ns0:GetAccountBalance>
</ns1:Body>
</SOAP-ENV:Envelope>
我的问题是,如何在不通过 SUDS 添加任何内容的情况下发送我的 XML?
My question is, how can I send my XML, without adding anything by SUDS?
推荐答案
根据 suds 文档,您可以使用 __inject
您正在调用的方法的参数:
According to the suds documentation, you can send a raw SOAP message using the __inject
argument to the method you're calling:
client.service.GetAccountBalance(__inject={'msg': xml})
这篇关于通过 SUDS 发送 xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!