我寫的自動交易機器人,使用Python和肥皂水SOAP客戶端。SOAP和持久性
我想知道是否可以通過使用持久的SOAP調用來提高速度(就像在RESTful服務中使用Session一樣)。
這裏是我的要求是什麼樣子:
DEBUG:suds.client:sending to (http://api.betdaq.com/v2.0/ReadOnlyService.asmx)
message:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://www.GlobalBettingExchange.com/ExternalAPI/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:None="http://www.GlobalBettingExchange.com/ExternalAPI/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<ns0:ExternalApiHeader xmlns="http://www.GlobalBettingExchange.com/ExternalAPI/" version="2" languageCode="en" username="****" password="****" applicationIdentifier="***"/>
</SOAP-ENV:Header>
<ns1:Body>
<ns0:GetPrices>
<getPricesRequest xmlns="http://www.GlobalBettingExchange.com/ExternalAPI/" NumberForPricesRequired="1" NumberAgainstPricesRequired="1">
<MarketIds>9430420</MarketIds>
</getPricesRequest>
</ns0:GetPrices>
</ns1:Body>
</SOAP-ENV:Envelope>
而我得到的迴應是:
DEBUG:suds.client:headers = {'SOAPAction': u'"http://www.GlobalBettingExchange.com/ExternalAPI/GetPrices"', 'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.client:http succeeded: *long xml here*
正如你可以看到我在每一個XML請求使用頁眉爲我的用戶名和密碼。但是當我得到迴應時,標題中沒有cookie。
我想知道是否有可能以某種方式插入餅乾到我的請求或類似的東西來實現持久性。 (像RESTful服務使用Session)
從來沒有真正起到用肥皂,但怎麼樣[這裏](http://stackoverflow.com/questions/21587554/extracting-cookie-from-soap-response-in-suds)+鹹菜(HTTPS:/ /docs.python.org/2/library/pickle.html)? – Arount
@Arount,你可以看到響應並沒有真正返回我可以插入下一個請求的任何cookie。 – Marijus