2011-12-09 36 views
3

我完全卡在ONVIF验证。我想我已经尝试过所有的东西,或者至少几乎所有东西,而且我在互联网上找不到足够的信息。我已创建使用SvcUtil工具,我的代码做认证存根客户(他们中的一个,因为我已经尝试了很多东西):使用轴卡马拉P1344的Onvif验证c#

string uri = "http://140.0.22.39/onvif/services"; 

EndpointAddress serviceAddressPrueba = new EndpointAddress(uri); 
HttpTransportBindingElement httpBinding = new HttpTransportBindingElement(); 
httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest; 
var messegeElement = new TextMessageEncodingBindingElement(); 
messegeElement.MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None); 
CustomBinding bindprueba = new CustomBinding(messegeElement, httpBinding); 
DeviceClient clientprueba = new DeviceClient(bindprueba, serviceAddressPrueba); 
string passwordDigestBase64; 
//HERE I PUT THE CODE TO ENCRYPT THE PASSWORD. 
PasswordDigestBehavior behavior1 = new PasswordDigestBehavior("root",passwordDigestBase64); 
clientprueba.Endpoint.Behaviors.Add(behavior1); 
string d1; 
string d2; 
string d3; 
string d4; 

clientprueba.GetDeviceInformation(out d1, out d2, out d3, out d4); 

在此之后有以下错误:

{"The remote server returned an unexpected response: (400) Bad Request."} 

如果你能帮我解决这个问题,我将非常非常感激。

+0

请检查http://stackoverflow.com/questions/18149866/unable-to-connect-to-onvif-enabled-camera-using-c-sharp/18623888#18623888 – mhcuervo

回答

0

几件事情可能会导致此:

  1. 你已经设置通过Web浏览器root密码,从而锁定用户ONVIF。登录到相机并添加一个ONVIF用户(有一个专门的页面)

  2. 您的密码摘要只包含密码,它应该包含随机随机数,创建时间和密码的串联。

  3. 您的本地时钟与相机的时钟不同步。调用getSystemDateAndTime来读取远程时钟并记录您之间的时间差异。

这些是3出来的那太慢了4点重要的事情(第4一个被导入WSDL,但它看起来像你得到它的话)

0

试试这个方法:

ServicePointManager.Expect100Continue = false; 
var endPointAddress = new EndpointAddress("http://" + cameraAddress + "/onvif/device_service"); 
var httpTransportBinding = new HttpTransportBindingElement { AuthenticationScheme = AuthenticationSchemes.Digest }; 
var textMessageEncodingBinding = new TextMessageEncodingBindingElement { MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None) }; 
var customBinding = new CustomBinding(textMessageEncodingBinding, httpTransportBinding); 
var passwordDigestBehavior = new PasswordDigestBehavior(adminName, adminPassword); 
var deviceClient = new DeviceClient(customBinding, endPointAddress); 
deviceClient.Endpoint.Behaviors.Add(passwordDigestBehavior); 

请注意,将ServicePointManager.Expect100Continue设置为false很重要。