【发布时间】:2020-11-18 02:35:10
【问题描述】:
我很害怕这一天会到来……处理 SOAP API 的……
这对我来说是一个全新的领域,我已经用 SAVON gem 进行了一些挖掘,但我似乎无法构建我的调用..
基本上我想做的是以下几点:
第一步:调用API获取LatestCallerVersion(API版本)
第 2 步:获取 LatestCallerVersion 并向验证 API 发送第二个请求,以查看我的客户是否在有效的服务区域内。
这是我想出的(但它会崩溃并烧毁)
caller_client = Savon.client(
wsdl: 'https://alarmadmin.alarm.com/webservices/CustomerManagement.asmx?WSDL '\
)
caller_response = caller_client.call(
:authentication,
message: {
user: 'xxxxxx',
password: 'xxxxxx',
two_factor_device_id: 'xxxxxx'
},
:body,
message: {
:get_latest_caller_version
}
)
这是 GetLatestCaller 调用的 SOAP 请求和响应文档
POST /webservices/CustomerManagement.asmx HTTP/1.1
Host: alarmadmin.alarm.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<Authentication xmlns="http://www.alarm.com/WebServices">
<User>string</User>
<Password>string</Password>
<TwoFactorDeviceId>string</TwoFactorDeviceId>
</Authentication>
</soap12:Header>
<soap12:Body>
<GetLatestCallerVersion xmlns="http://www.alarm.com/WebServices" />
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetLatestCallerVersionResponse xmlns="http://www.alarm.com/WebServices">
<GetLatestCallerVersionResult>int</GetLatestCallerVersionResult>
</GetLatestCallerVersionResponse>
</soap12:Body>
</soap12:Envelope>
这里是 CheckCaller_V2 请求和响应
POST /webservices/Validate.asmx HTTP/1.1
Host: alarmadmin.alarm.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<Authentication xmlns="http://www.alarm.com/WebServices">
<User>string</User>
<Password>string</Password>
<TwoFactorDeviceId>string</TwoFactorDeviceId>
</Authentication>
</soap12:Header>
<soap12:Body>
<CheckCoverage_v2 xmlns="http://www.alarm.com/WebServices">
<input>
<Address>
<Street1>string</Street1>
<Street2>string</Street2>
<SubCity>string</SubCity>
<City>string</City>
<SubState>string</SubState>
<State>string</State>
<Zip>string</Zip>
<CountryId>Canada</CountryId>
</Address>
<Network>Gsm</Network>
<Generation>FourG</Generation>
<CallerVersion>returned from GetLatestCaller call</CallerVersion>
</input>
</CheckCoverage_v2>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<CheckCoverage_v2Response xmlns="http://www.alarm.com/WebServices">
<CheckCoverage_v2Result>NotChecked or FullCoverage or MostlyCovered or NoCoverage or Error or BadZip or PartialCoverage or NotSupported or NotOffered</CheckCoverage_v2Result>
</CheckCoverage_v2Response>
</soap12:Body>
</soap12:Envelope>
我是 SOAP 的新手,我们将不胜感激任何帮助。如果需要任何进一步的信息,请告诉我。
【问题讨论】:
标签: ruby-on-rails soap savon