Soap 使用ONVIF摄像头进行身份验证时Http 400错误请求

Soap 使用ONVIF摄像头进行身份验证时Http 400错误请求,soap,camera,ip,onvif,usernametoken,Soap,Camera,Ip,Onvif,Usernametoken,我试图通过发送usernametoken soap请求来获得设备功能,从而通过ONVIF摄像机进行身份验证。但是我正在获取请求的操作,需要授权,并且发送者未被授权错误从相机返回。下面是我正在发送的Usernametoken: <?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Secur

我试图通过发送usernametoken soap请求来获得设备功能,从而通过ONVIF摄像机进行身份验证。但是我正在获取请求的操作,需要授权,并且发送者未被授权错误从相机返回。下面是我正在发送的Usernametoken:

<?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>root</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">PLAolzuaeKGkHrC7uMD52ZAvjDc=</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">DK81s1X+o0Cp0QfDg7CJ8YSeacg=</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2015-02-12T21:49:39.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"><GetCapabilities xmlns="http://www.onvif.org/ver10/device/wsdl"><Category>All</Category></GetCapabilities></s:Body></s:Envelope>
我正在以这种方式创建:

string guid = Guid.NewGuid().ToString();
string nonce = GetSHA1String( guid );

public string GetSHA1String(string phrase)
{
        byte[] hashedDataBytes = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(phrase)); 
        return Convert.ToBase64String(hashedDataBytes);
}
string created = System.DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
string pwd = "admin";
string hashedPassword = CreateHashedPassword(nonce, created, pwd);

 public string CreateHashedPassword(string nonce, string created, string password)
 {
       return GetSHA1String(nonce + created + password);
 }
我以以下方式创建PasswordDigest:

string guid = Guid.NewGuid().ToString();
string nonce = GetSHA1String( guid );

public string GetSHA1String(string phrase)
{
        byte[] hashedDataBytes = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(phrase)); 
        return Convert.ToBase64String(hashedDataBytes);
}
string created = System.DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ");
string pwd = "admin";
string hashedPassword = CreateHashedPassword(nonce, created, pwd);

 public string CreateHashedPassword(string nonce, string created, string password)
 {
       return GetSHA1String(nonce + created + password);
 }

我不知道我做错了什么。我真的很感激有人能在这件事上帮忙

散列时,nonce+created+密码的nonce部分必须是二进制数据。有关类似问题,请参阅此线程: