【问题标题】:SOAP and persistanceSOAP 和持久性
【发布时间】:2017-04-20 15:32:23
【问题描述】:

我正在编写自动交易机器人,使用 python 和 suds 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。

我想知道是否有可能以某种方式将 cookie 插入我的请求或类似的东西以实现持久性。 (就像在 RESTful 服务中使用 Session)

【问题讨论】:

  • 从来没有真正玩过肥皂,但是this + pickle 呢?
  • @Arount 如您所见,响应并没有真正返回任何我可以插入到下一个请求中的 cookie。

标签: python web-services cookies soap


【解决方案1】:

没有。您受服务器响应的支配——据我所知,它不会返回任何 cookie。

存在一个加速 HTTP 基本身份验证的极端情况,允许抢先发送凭据,但不适用。

确保重复使用 HTTPS 连接。

【讨论】:

  • 是的,服务器不返回任何 cookie。我正在使用相同的客户端对象向服务器发出请求 - 所以我猜我正在使用持久连接?
  • 通常是的。那么你可以提出并行请求吗?
  • 好的,确保连接池(如果有的话)有足够的连接。
猜你喜欢
  • 2017-01-15
  • 2011-10-18
  • 1970-01-01
  • 2013-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多