创建第一个用户后(在我的情况下,用户名为"root",密码为"root"),对于任何onvif请求,AXIS P3301(固件5.11.2)都会返回NotAuthorized soap fault:
<SOAP-ENV:Fault
SOAP-ENV:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
<SOAP-ENV:Code>
<SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value>
<SOAP-ENV:Subcode>
<SOAP-ENV:Value>ter:NotAuthorized</SOAP-ENV:Value>
</SOAP-ENV:Subcode>
</SOAP-ENV:Code>
<SOAP-ENV:Reason>
<SOAP-ENV:Text xml:lang="en">Sender not authorized</SOAP-ENV:Text>
</SOAP-ENV:Reason>
<SOAP-ENV:Detail>
The action requested requires authorization and the sender is not authorized
</SOAP-ENV:Detail>
</SOAP-ENV:Fault>
Run Code Online (Sandbox Code Playgroud)
根据ONVIF规范1.02,我使用用户名令牌配置文件 进行身份验证,详见http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0 .pdf.
下面是我用来形成soap请求的脚本:
xquery version "1.0";
declare copy-namespaces no-preserve, inherit;
<s:Envelope
xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<o:Security
s:mustUnderstand="true"
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken u:Id="UsernameToken-3ae8d972-d014-47b0-858b-2364f6119763">
<o:Username>{model/userName/text()}</o:Username>
<o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">
{model/passwordDigest/text()}
</o:Password>
<o:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
{model/nonce/text()}
</o:Nonce>
<u:Created>{model/created/text()}</u:Created>
</o:UsernameToken>
</o:Security>
</s:Header>
<s:Body>
<tds:GetDeviceInformation xmlns:tds="http://www.onvif.org/ver10/device/wsdl" />
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是我发送请求的代码:
static …Run Code Online (Sandbox Code Playgroud)