由于 SOAP 通过 HTTP 工作,因此您只需向那里发送一个 HTTP 请求。例如通过 CURL,它会是这样的:
curl 10.10.10.10:1234/onvif/device_service -d '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSystemDateAndTime xmlns="http://www.onvif.org/ver10/device/wsdl"/></s:Body></s:Envelope>'
结果,您将获得带有一些标题的类似内容:
<tds:GetSystemDateAndTimeResponse>
<tds:SystemDateAndTime>
<tt:DateTimeType>Manual</tt:DateTimeType>
<tt:DaylightSavings>false</tt:DaylightSavings>
<tt:TimeZone>
<tt:TZ>MoroccoStandardTime0</tt:TZ>
</tt:TimeZone>
<tt:UTCDateTime>
<tt:Time>
<tt:Hour>10</tt:Hour>
<tt:Minute>5</tt:Minute>
<tt:Second>35</tt:Second>
</tt:Time>
<tt:Date>
<tt:Year>2014</tt:Year>
<tt:Month>3</tt:Month>
<tt:Day>14</tt:Day>
</tt:Date>
</tt:UTCDateTime>
</tds:SystemDateAndTime>
</tds:GetSystemDateAndTimeResponse>
并且不要忘记大多数操作都需要在请求中包含授权标头。
验证
在第 35 页的 ONVIF 应用程序程序员指南中描述了如何完成身份验证。例如,它看起来像这样:
<s:Header>
<Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken>
<Username>admin</Username>
<Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">MuMnyh3wTxGWOCc=</Password>
<Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">8Qqve9KCkNhQAAAAAAA==</Nonce>
<Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2014-03-04T14:03:05.130Z</Created>
</UsernameToken>
</Security>
</s:Header>