2017-04-15 147 views
0

我写的自动交易机器人,使用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)

+0

从来没有真正起到用肥皂,但怎么样[这里](http://stackoverflow.com/questions/21587554/extracting-cookie-from-soap-response-in-suds)+咸菜(HTTPS:/ /docs.python.org/2/library/pickle.html)? – Arount

+0

@Arount,你可以看到响应并没有真正返回我可以插入下一个请求的任何cookie。 – Marijus

回答

0

号您是在服务器响应的怜悯 - 我的理解不返回任何cookie。

存在增加HTTP基本身份验证的角落案例,使抢先发送凭据,但不适用。

确保HTTPS连接被重新使用。

+0

是的,服务器不返回任何cookie。我使用的是同一个客户端的对象发出请求到服务器 - 所以我猜我使用的持久连接? – Marijus

+0

通常是的。那么你是否可以提出并行请求? – ThomasRS

+0

是的。实际上我使用的是并行请求。 – Marijus