<legend id='Z32WC'><style id='Z32WC'><dir id='Z32WC'><q id='Z32WC'></q></dir></style></legend>

    <tfoot id='Z32WC'></tfoot>
    • <bdo id='Z32WC'></bdo><ul id='Z32WC'></ul>

    1. <i id='Z32WC'><tr id='Z32WC'><dt id='Z32WC'><q id='Z32WC'><span id='Z32WC'><b id='Z32WC'><form id='Z32WC'><ins id='Z32WC'></ins><ul id='Z32WC'></ul><sub id='Z32WC'></sub></form><legend id='Z32WC'></legend><bdo id='Z32WC'><pre id='Z32WC'><center id='Z32WC'></center></pre></bdo></b><th id='Z32WC'></th></span></q></dt></tr></i><div id='Z32WC'><tfoot id='Z32WC'></tfoot><dl id='Z32WC'><fieldset id='Z32WC'></fieldset></dl></div>

      <small id='Z32WC'></small><noframes id='Z32WC'>

        如何生成 GetSystemDateAndTime xml

        How to generate GetSystemDateAndTime xml(如何生成 GetSystemDateAndTime xml)

            <bdo id='C50KI'></bdo><ul id='C50KI'></ul>

            <legend id='C50KI'><style id='C50KI'><dir id='C50KI'><q id='C50KI'></q></dir></style></legend>

              <small id='C50KI'></small><noframes id='C50KI'>

              <tfoot id='C50KI'></tfoot>

              <i id='C50KI'><tr id='C50KI'><dt id='C50KI'><q id='C50KI'><span id='C50KI'><b id='C50KI'><form id='C50KI'><ins id='C50KI'></ins><ul id='C50KI'></ul><sub id='C50KI'></sub></form><legend id='C50KI'></legend><bdo id='C50KI'><pre id='C50KI'><center id='C50KI'></center></pre></bdo></b><th id='C50KI'></th></span></q></dt></tr></i><div id='C50KI'><tfoot id='C50KI'></tfoot><dl id='C50KI'><fieldset id='C50KI'></fieldset></dl></div>
                  <tbody id='C50KI'></tbody>
                • 本文介绍了如何生成 GetSystemDateAndTime xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有以下从

                  需要什么代码才能将 xml 更改为如下所示:

                  我应该如何调用 GetSystemDateAndTime 函数?

                  要调用 GetProfiles 函数,我必须创建一个 MediaClient,然后调用该函数...

                  是否有 MediaClient 之类的东西可以访问 GetSystemDateAndTime??

                  我发现您可以使用 DeviceClient 来访问 GetSystemDateAndTime 函数...

                  您需要先将设备管理 wsdl 添加到您连接的服务中:https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl

                  我还在其中添加了 System.Net.ServicePointManager.Expect100Continue = false; 因为我看到有人在 这个链接...

                  所以我补充说:

                  CustomBinding 绑定 = new CustomBinding(messageElement, httpBinding);System.Net.ServicePointManager.Expect100Continue = false;DeviceClient d = new DeviceClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/device_service"));var time = d.GetSystemDateAndTime();

                  注意:我仍然收到错误消息:

                   ErrorMessage "来自命名空间 'http://www.w3.org/2005/08/addressing' 的标头 'To' 不被此消息的接收者理解,导致消息未被处理. 此错误一般表示此消息的发送方启用了接收方无法处理的通信协议.请确保客户端绑定的配置与服务的绑定一致." string

                  解决方案

                  这个错误是说尝试阅读消息时出现问题,所以我认为这可能是由于某种编码......

                  我是对的!!

                  我所要做的就是在 TextMessageEncodingBindingElement 的创建中更改一个参数.

                  MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10)

                  您需要做的就是确保您拥有良好的encodingAuthenticationScheme...

                  这是我获取 onvif 相机(此处为 cohuHD 相机)系统以及日期和时间设置的最终代码:

                  public bool Initialise(string cameraAddress, string userName, string password){布尔结果=假;尝试{var messageElement = new TextMessageEncodingBindingElement(){MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10)};HttpTransportBindingElement httpBinding = 新的 HttpTransportBindingElement(){AuthenticationScheme = AuthenticationSchemes.Digest};CustomBinding 绑定 = new CustomBinding(messageElement, httpBinding);System.Net.ServicePointManager.Expect100Continue = false;DeviceClient deviceClient = new DeviceClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/device_service"));var temps = deviceClient.GetSystemDateAndTime();}捕捉(例外前){ErrorMessage = ex.Message;}返回结果;}

                  奖励:

                  如果你想执行一个需要凭据的函数,你可以像这样将它们添加到你的 deviceClient 中:

                  //DIGEST (httpBinding)deviceClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;deviceClient.ClientCredentials.HttpDigest.ClientCredential.UserName = 用户名;deviceClient.ClientCredentials.HttpDigest.ClientCredential.Password = 密码;

                  还要注意 EndpointAddress 的 URL...我认为有些相机使用 Device_service 和其他 device_service.

                  I have the following bit of code that i took from this source...

                  public bool Initialise(string cameraAddress, string userName, string password)
                      {
                          bool result = false;
                  
                          try
                          {
                              var messageElement = new TextMessageEncodingBindingElement()
                              {
                                  MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
                              };
                  
                              HttpTransportBindingElement httpBinding = new HttpTransportBindingElement()
                              {
                                  AuthenticationScheme = AuthenticationSchemes.Digest
                              };
                  
                              CustomBinding bind = new CustomBinding(messageElement, httpBinding);
                  
                  
                              mediaClient = new MediaClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/Media"));
                              mediaClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                              mediaClient.ClientCredentials.HttpDigest.ClientCredential.UserName = userName;
                              mediaClient.ClientCredentials.HttpDigest.ClientCredential.Password = password;
                  
                              var profs = mediaClient.GetProfiles();
                  
                              //rest of the code...
                  

                  When i run wireshark while going through the GetProfiles() part in the debugger, I see that the generated XML looks like:

                  What code would it take to change the xml to look like:

                  How am i supposed to call the GetSystemDateAndTime function?

                  To call the GetProfiles function, I had to create a MediaClient and, then, call that function...

                  Is there such thing as a MediaClient to get access to the GetSystemDateAndTime??

                  Edit:

                  I found that you could use the DeviceClient to get access the the GetSystemDateAndTime function...

                  You'll need to add the device management wsdl to your connected services before: https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl

                  I also added System.Net.ServicePointManager.Expect100Continue = false; in there because i saw someone said it helped at this link...

                  So i added :

                  CustomBinding bind = new CustomBinding(messageElement, httpBinding);
                  System.Net.ServicePointManager.Expect100Continue = false;
                  DeviceClient d = new DeviceClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/device_service"));
                  var time = d.GetSystemDateAndTime();
                  

                  Note: I'm still getting the error:

                          ErrorMessage    "The header 'To' from the namespace 'http://www.w3.org/2005/08/addressing' was not understood by the recipient of this message, causing the message to not be processed.  This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process.  Please ensure that the configuration of the client's binding is consistent with the service's binding. "   string
                  

                  解决方案

                  This error is saying that there is trouble when trying to read a message, so i tough it was probably due to some sort of encoding ...

                  AND I WAS RIGHT!!

                  All I had to do was changing a parameter in the TextMessageEncodingBindingElement's creation.

                  MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10)
                  

                  All you need to do is make sure that you have good encoding and AuthenticationScheme...

                  Here's my final code to get an onvif camera's (here cohuHD camera) system and date and time settings:

                  public bool Initialise(string cameraAddress, string userName, string password)
                      {
                          bool result = false;
                  
                          try
                          {
                              var messageElement = new TextMessageEncodingBindingElement()
                              {
                                  MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.WSAddressing10)
                              };
                  
                              HttpTransportBindingElement httpBinding = new HttpTransportBindingElement()
                              {
                                  AuthenticationScheme = AuthenticationSchemes.Digest
                              };
                  
                              CustomBinding bind = new CustomBinding(messageElement, httpBinding);
                  
                              System.Net.ServicePointManager.Expect100Continue = false;
                  
                              DeviceClient deviceClient = new DeviceClient(bind, new EndpointAddress($"http://{cameraAddress}/onvif/device_service"));
                  
                              var temps = deviceClient.GetSystemDateAndTime();
                          }
                          catch (Exception ex)
                          {
                              ErrorMessage = ex.Message;
                          }
                          return result;
                      }
                  

                  Bonus:

                  If you want to execute a function that needs credentials, you can add those to your deviceClient like so:

                  //DIGEST (httpBinding)
                  deviceClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                  deviceClient.ClientCredentials.HttpDigest.ClientCredential.UserName = userName;
                  deviceClient.ClientCredentials.HttpDigest.ClientCredential.Password = password;
                  

                  Watch out also for the EndpointAddress' URL... I think some cameras use Device_service and other device_service .

                  这篇关于如何生成 GetSystemDateAndTime xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                    <tbody id='488hR'></tbody>
                • <i id='488hR'><tr id='488hR'><dt id='488hR'><q id='488hR'><span id='488hR'><b id='488hR'><form id='488hR'><ins id='488hR'></ins><ul id='488hR'></ul><sub id='488hR'></sub></form><legend id='488hR'></legend><bdo id='488hR'><pre id='488hR'><center id='488hR'></center></pre></bdo></b><th id='488hR'></th></span></q></dt></tr></i><div id='488hR'><tfoot id='488hR'></tfoot><dl id='488hR'><fieldset id='488hR'></fieldset></dl></div>

                      <legend id='488hR'><style id='488hR'><dir id='488hR'><q id='488hR'></q></dir></style></legend>
                      <tfoot id='488hR'></tfoot>

                        <small id='488hR'></small><noframes id='488hR'>

                          <bdo id='488hR'></bdo><ul id='488hR'></ul>