ONVIF反序列化操作'GetStatus'的回复消息正文时出错->字符串'1532531507'不是有效的AllXsd值

时间:2018-07-25 16:00:19

标签: c# xml onvif

上下文:

我正在制作一个c#Windows窗体应用程序,它使用onvif网站上提供的wsdls与ONVIF相机进行通讯。

https://www.onvif.org/ver10/media/wsdl/media.wsdl

https://onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl

我能够在相机上获取个人资料,发送PTZ动作等等,但是当我尝试获取我创建的ptzClient的状态时,出现错误:

Error in deserializing body of reply message for operation 'GetStatus'

我查看了此错误的innerException来查找:

The string '1532531507' is not a valid AllXsd value.

这是我创建ptzClient的方式:

ServicePointManager.Expect100Continue = false;
var commonEncoding = new TextMessageEncodingBindingElement
                {
                    MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None)
                };
var commonBinding = new HttpTransportBindingElement
                {
                    AuthenticationScheme = AuthenticationSchemes.Digest
                };
var commonCustomBinding = new CustomBinding(commonEncoding, commonBinding);
var commonPasswordDigestBehavior = new PasswordDigestBehavior(userName, password);
var ptzEndpointAddress = new EndpointAddress($"http://{cameraAddress}/onvif/ptz");
ptzClient = new PTZClient(commonCustomBinding, ptzEndpointAddress);
ptzClient.Endpoint.EndpointBehaviors.Add(commonPasswordDigestBehavior);

调用以下代码行时发生错误:

var p = ptzClient.GetStatus(profile.token);

当我在Wireshark中看到我的xml请求及其对应的xml响应时,我看到没有错误: enter image description here

问题:

如何在不出现这些错误的情况下拨打电话?

我没有什么可以改变的...

问题似乎出在日期格式上,但我看不到更改此格式的方法。

1 个答案:

答案 0 :(得分:0)

要知道相机设备是否支持PTZ,可以在设备服务上调用GetCapabilities。

GetCapabilities列表包含对实现类别中的接口操作的服务(在您的情况下为PTZ服务)地址(XAddr)的引用。如果“ GetCapabilities”列表中未列出PTZ服务,则您的设备不支持PTZ。

GetStatus api仅返回所选配置文件中节点的PTZ状态。

有一些ONVIF测试工具可用于在Windows平台上测试您的相机,从而简化开发过程。 http://www.happytimesoft.com/products/onvif-client/index.html