尝试使用SOAP XML与Postman拨打国家铁路API,但获得“401 - 未经授权:由于凭证无效而拒绝访问”响应。这就是我所拥有的:
地址栏
POST https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb10.asmx
标题:
Content-Type: text/xml;charset=UTF-8
SOAPAction: http://thalesgroup.com/RTTI/2017-02-02/ldb/GetDepartureBoard
Accept-encoding: gzip, x-gzip, deflate, x-bzip2
体:
<soap:Envelope
xmlns:ldb="http://thalesgroup.com/RTTI/2017-02-02/ldb/"
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:typ="http://thalesgroup.com/RTTI/2017-02-02/Token/types">
<soap:Header>
<typ:AccessToken>
<typ:TokenValue>**** token removed ****</typ:TokenValue>
</typ:AccessToken>
</soap:Header>
<soap:Body>
<ldb:GetDepartureBoardRequest>
<ldb:crs>LST</ldb:crs>
<ldb:numRows>10</ldb:numRows>
<ldb:timeOffset>0</ldb:timeOffset>
<ldb:timeWindow>120</ldb:timeWindow>
</ldb:GetDepartureBoardRequest>
</soap:Body>
</soap:Envelope>
有些文档在这里:https://lite.realtime.nationalrail.co.uk/openldbws/
此处调用示例:http://nrodwiki.rockshore.net/index.php/GetDepBoardWithDetails
任何帮助都会受到赞赏 - 我想了解如何正确地进行API调用,以便我可以使用我的业余爱好项目应用程序。
答案 0 :(得分:1)
将地址更改为:
https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ldb9.asmx
更改肥皂:信封
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:typ="http://thalesgroup.com/RTTI/2013-11-28/Token/types"
xmlns:ldb="http://thalesgroup.com/RTTI/2016-02-16/ldb/">
如果您使用有效的令牌,这将有效(我已在Postman中测试过)。
希望有所帮助。