2017-05-11 4 views
0

私はonvif準拠のカメラにWebリクエストをしようとしていますが、私は応答に問題があります。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> 

イム計算自分のコンピュータとデバイスの間のオフセットの差分を差し引いた時間を作成し、メッセージがデバイスと互換性のある日時で送信されるようにします。

私のリクエストに何か不足していますか?ユーザー名とパスワードが正しいことを考慮すると、この問題の原因は何ですか?

答えて

0

したがって、オンとオフの研究と試行錯誤の後、私は私の問題を解決することができました。私は、ONVIFデバイスマネージャアプリケーションはカメラに送信されたかどうか確認するためのwiresharkを使用して、このメッセージになってしまった:

<?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> 

ナンスとパスワードが、私はまた、私が使っていた方法を変更し、これで終わったダイジェストを計算するには1:

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; 

     } 

この方法は、大きく、残念ながら私は、リンクや人の名前を保存するのを忘れ、ここにStackOverflowで別の質問によその回答に基づいています。 これは私が同じロードブロッキングにいる人々に役立つことを願っています。

関連する問題