2017-05-11 2 views
0

나는 onvif 호환 카메라로 웹 요청을하려고하는데 응답에 문제가 있습니다. ONVIF GetDeviceInformation SOAP 메시지

내가 ONVIF 응용 프로그램 프로그래머의 가이드를 따라 난 장치 정보를 얻기 위해이 SOAP 메시지를 내놓았다 :

<?xml version="1.0" encoding="utf-8"?> 
<s:Envelope 
    xmlns:s="http://www.w3.org/2003/05/soap-envelope" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:tt="http://www.onvif.org/ver10/schema" 
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" 
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    xmlns:tds="http://www.onvif.org/ver10/device/wsdl"> 
    <s:Header> 
     <wsse:Security> 
      <wsse:Username>admin</wsse:Username> 
      <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-token-profile-1.0#PasswordDigest"> 
       WndlORLsIdMIyyvb99lzSgm0iGI= 
      </wsse:Password> 
      <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"> 
       Rjc0QUUzNDI2MTMyMTI4OTJCQjI1QzM2RUEzMDUzNEUxMTlFNEQ2Mg== 
      </wsse:Nonce> 
      <wsu:Created>2017-05-11T11:48:56.8823852ZZ</wsu:Created> 
     </wsse:Security> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <GetDeviceInformation xmlns="http://www.onvif.org/ver10/device/wsdl" /> 
    </s:Body> 
</s:Envelope> 

그리고 장치의 응답입니다 :

<SOAP-ENV:Envelope (...)> 
    <SOAP-ENV:Header> 
    </SOAP-ENV:Header> 
    <SOAP-ENV:Body> 
     <SOAP-ENV:Fault> 
      <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:Fault> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

임은 계산 내 컴퓨터와 장치 간의 오프셋 차이를 뺀 시간을 만들어 메시지가 장치와 호환되는 datetime으로 보내집니다.

요청 사항에 누락 된 것이 있습니까? 사용자 이름과 암호가 맞다고 생각하면이 문제의 원인은 무엇입니까?

답변

0

따라서 일부 조사 및 시험 후 오류가 발생하여 문제를 해결할 수있었습니다. 나는 ONVIF 장치 관리자 응용 프로그램이 카메라에 전송 된 것을 확인하기 위해 와이어 샤크를 사용하고이 메시지와 함께 결국 :

<?xml version="1.0" encoding="utf-8"?> 
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> 
    <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">6KZX13jsvYLOE72Fb7Nc4tCFE60=</Password> 
       <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">Xd0vNthkfp/VCmVtoHr3QA==</Nonce> 
       <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2017-06-01T10:29:01.001Z</Created> 
      </UsernameToken> 
     </Security> 
    </s:Header> 
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
     <GetDeviceInformation xmlns="http://www.onvif.org/ver10/device/wsdl" /> 
    </s:Body> 
</s:Envelope> 

비표를 계산하고 암호가 내가이와 내가 사용하던 방법을 변경하고 결국 소화 하나 :이 방법은 주로 여기에 StackOverflow에서 다른 질문에 누군가를 elses 대답을 기반으로

public static void GetPasswordDigest(string ONVIFPassword, TimeSpan CameraTimeOffset, out string nonceb64_out, out string created_out, out string passwordDigest_out) 
     { 
      //Get nonce 
      Random rnd = new Random(); 
      Byte[] nonce_b = new Byte[16]; 
      rnd.NextBytes(nonce_b); 
      string nonce64 = Convert.ToBase64String(nonce_b); 
      nonceb64_out = nonce64; 

      //Get timestamp 
      DateTime created = DateTime.UtcNow - CameraTimeOffset; 
      string creationtime = created.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"); 
      Byte[] creationtime_b = Encoding.ASCII.GetBytes(creationtime); 
      created_out = creationtime; 

      //Convert the plain password to bytes 
      Byte[] password_b = Encoding.ASCII.GetBytes(ONVIFPassword); 

      //Concatenate nonce_b + creationtime_b + password_b 
      Byte[] concatenation_b = new byte[nonce_b.Length + creationtime_b.Length + password_b.Length]; 
      System.Buffer.BlockCopy(nonce_b, 0, concatenation_b, 0, nonce_b.Length); 
      System.Buffer.BlockCopy(creationtime_b, 0, concatenation_b, nonce_b.Length, creationtime_b.Length); 
      System.Buffer.BlockCopy(password_b, 0, concatenation_b, nonce_b.Length + creationtime_b.Length, password_b.Length); 

      //Apply SHA1 on the concatenation 
      SHA1 sha = new SHA1CryptoServiceProvider(); 
      Byte[] pdresult = sha.ComputeHash(concatenation_b); 
      string passworddigest = Convert.ToBase64String(pdresult); 
      passwordDigest_out = passworddigest; 

     } 

은, 불행하게도 내가 링크 또는 사람의 이름을 저장하는 것을 잊었다. 나는 이것이 동일한 장애물에있는 사람들에게 도움이되기를 바랍니다.