[英]How to get the soap envelope with suds python
How can I get the soap envelope,and how can I change the values before sending to server. 如何获得肥皂信封,以及如何在发送到服务器之前更改其值。
ex: Soap envelope 例如:肥皂信封
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ws="http://www.altoromutual.com/bank/ws/">
<soap:Header/>
<soap:Body>
<ws:TransferBalance>
<!--Optional:-->
<ws:transDetails>
<ws:transferDate>2013-01-01T00:00:00</ws:transferDate>
<!--Optional:-->
<ws:debitAccount>1001160141</ws:debitAccount>
<!--Optional:-->
<ws:creditAccount>1001160140</ws:creditAccount>
<ws:transferAmount>2.0</ws:transferAmount>
</ws:transDetails>
</ws:TransferBalance>
I want to hold this envelope and change the values before sending to server.How can I do it with suds 我想保留这个信封并在发送到服务器之前更改其值。如何用肥皂水处理
Thanks 谢谢
If I understood the question correctly, you don't necessarily need to use suds to modify the envelope. 如果我正确理解了这个问题,则不必使用泡沫来修改信封。 Instead you can save the request as a template, use your favorite templating engine to change any values you need to change, and pass the whole request to the suds call using the
__inject
parameter. 相反,您可以将请求另存为模板,使用喜欢的模板引擎来更改需要更改的任何值,然后使用
__inject
参数将整个请求传递给__inject
调用。
Here's a simple example: 这是一个简单的例子:
import suds
from mako.template import Template
WSDL = 'https://example.com/someservice?wsdl'
client = suds.client.Client(WSDL)
template = Template(filename='template.xml')
request = template.render(debitaccount='someaccount', creditaccount='anotheraccount')
response = client.service.some_call(__inject={'msg':request})
And the template 和模板
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ws="http://www.altoromutual.com/bank/ws/">
<soap:Header/>
<soap:Body>
<ws:TransferBalance>
<!--Optional:-->
<ws:transDetails>
<ws:transferDate>2013-01-01T00:00:00</ws:transferDate>
<!--Optional:-->
<ws:debitAccount>${debitaccount}</ws:debitAccount>
<!--Optional:-->
<ws:creditAccount>${creditaccount}</ws:creditAccount>
<ws:transferAmount>2.0</ws:transferAmount>
</ws:transDetails>
</ws:TransferBalance>
</soap:Body>
</soap:Envelope>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.