立羽丶 2024-12-11 11:18 采纳率: 50%
浏览 70
已结题

Onvif Device Manager提示“对操作"GetProfiles”的回复消息正文进行反序列化时出错”问题

最近在进行Onvif设备端开发,通过Onvif devcies manager能够扫描到设备,但是会报错,如下截图所示,请问下这个可能是什么原因。

img


摄像头端GetProfiles应答信息如下:

HTTP/1.1 200 OK
Server: gSOAP/2.8
X-Frame-Options: SAMEORIGIN
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 5054
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:saml1="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:wsc="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ns3="http://www.w3.org/2005/08/addressing" xmlns:ns1="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:w3xop="http://www.w3.org/2004/08/xop/include" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:ns2="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl" xmlns:tds="http://www.onvif.org/ver10/device/wsdl" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl" xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl" xmlns:trt="http://www.onvif.org/ver10/media/wsdl">
  <SOAP-ENV:Body>
    <trt:GetProfilesResponse>
      <trt:Profiles token="MainProfileToken" fixed="true">
        <tt:Name>MainProfile</tt:Name>
        <tt:VideoSourceConfiguration token="VideoSourceCfgToken_0">
          <tt:Name>VideoSourceCfg0</tt:Name>
          <tt:UseCount>1</tt:UseCount>
          <tt:SourceToken>VideoSourceToken_0</tt:SourceToken>
          <tt:Bounds x="0" y="0" width="1280" height="720">
          </tt:Bounds>
        </tt:VideoSourceConfiguration>
        <tt:AudioSourceConfiguration token="AudioSourceCfgToken_0">
          <tt:Name>AudioSourceCfg0</tt:Name>
          <tt:UseCount>1</tt:UseCount>
          <tt:SourceToken>AudioSourceToken_0</tt:SourceToken>
        </tt:AudioSourceConfiguration>
        <tt:VideoEncoderConfiguration token="VideoEncoderCfgToken_0">
          <tt:Name>VideoEncoderCfg0</tt:Name>
          <tt:UseCount>1</tt:UseCount>
          <tt:Encoding>H264</tt:Encoding>
          <tt:Resolution>
            <tt:Width>1280</tt:Width>
            <tt:Height>720</tt:Height>
          </tt:Resolution>
          <tt:Quality>70</tt:Quality>
          <tt:RateControl>
            <tt:FrameRateLimit>25</tt:FrameRateLimit>
            <tt:EncodingInterval>1</tt:EncodingInterval>
            <tt:BitrateLimit>4096</tt:BitrateLimit>
          </tt:RateControl>
          <tt:H264>
            <tt:GovLength>25</tt:GovLength>
            <tt:H264Profile>Main</tt:H264Profile>
          </tt:H264>
          <tt:Multicast />
          <tt:SessionTimeout />
        </tt:VideoEncoderConfiguration>
        <tt:AudioEncoderConfiguration token="AudioEncoderCfgToken_0">
          <tt:Name>AudioEncoderCfg0</tt:Name>
          <tt:UseCount>1</tt:UseCount>
          <tt:Encoding>G711</tt:Encoding>
          <tt:Bitrate>64</tt:Bitrate>
          <tt:SampleRate>48</tt:SampleRate>
          <tt:Multicast />
          <tt:SessionTimeout />
        </tt:AudioEncoderConfiguration>
        <tt:PTZConfiguration token="PTZCfgToken_0">
          <tt:Name>PTZConfigurations_0</tt:Name>
          <tt:UseCount>1</tt:UseCount>
          <tt:NodeToken>ptznode_token_0</tt:NodeToken>
          <tt:DefaultAbsolutePantTiltPositionSpace>http://www.onvif.org/ver10/tptz/PanTiltSpaces/DigitalPositionSpace</tt:DefaultAbsolutePantTiltPositionSpace>
          <tt:DefaultAbsoluteZoomPositionSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/PositionGenericSpace</tt:DefaultAbsoluteZoomPositionSpace>
          <tt:DefaultRelativePanTiltTranslationSpace>http://www.onvif.org/ver10/tptz/PanTiltSpaces/DigitalTranslationSpace</tt:DefaultRelativePanTiltTranslationSpace>
          <tt:DefaultRelativeZoomTranslationSpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/TranslationGenericSpace</tt:DefaultRelativeZoomTranslationSpace>
          <tt:DefaultContinuousPanTiltVelocitySpace>http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace</tt:DefaultContinuousPanTiltVelocitySpace>
          <tt:DefaultContinuousZoomVelocitySpace>http://www.onvif.org/ver10/tptz/ZoomSpaces/VelocityGenericSpace</tt:DefaultContinuousZoomVelocitySpace>
          <tt:DefaultPTZSpeed>
            <tt:PanTilt x="0.5" y="0.5" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/GenericSpeedSpace">
            </tt:PanTilt>
            <tt:Zoom x="0.5" space="http://www.onvif.org/ver10/tptz/ZoomSpaces/ZoomGenericSpeedSpace">
            </tt:Zoom>
          </tt:DefaultPTZSpeed>
          <tt:DefaultPTZTimeout>100</tt:DefaultPTZTimeout>
          <tt:PanTiltLimits>
            <tt:Range>
              <tt:URI>http://www.onvif.org/ver20/ptz/wsdl</tt:URI>
              <tt:XRange>
                <tt:Min>-1</tt:Min>
                <tt:Max>1</tt:Max>
              </tt:XRange>
              <tt:YRange>
                <tt:Min>-1</tt:Min>
                <tt:Max>3</tt:Max>
              </tt:YRange>
            </tt:Range>
          </tt:PanTiltLimits>
          <tt:ZoomLimits>
            <tt:Range>
              <tt:URI>http://www.onvif.org/ver20/ptz/wsdl</tt:URI>
              <tt:XRange>
                <tt:Min>0</tt:Min>
                <tt:Max>1</tt:Max>
              </tt:XRange>
            </tt:Range>
          </tt:ZoomLimits>
        </tt:PTZConfiguration>
      </trt:Profiles>
    </trt:GetProfilesResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


  • 写回答

11条回答 默认 最新

  • 问答-莫得感情 2024-12-11 14:09
    关注

    ️题主您好️,目前由我为您解答👇🏼
    🧡参考谷歌智能助手,由吾为汝整理提供🧡

    Onvif Device Manager报错“对操作"GetProfiles”的回复消息正文进行反序列化时出错”,尽管设备被发现,表明你的ONVIF设备在回复GetProfiles请求时,返回的XML数据格式存在问题,导致Onvif Device Manager无法解析。 错误并不在于Onvif Device Manager,而在于你设备端的回复。

    根据你提供的XML响应,问题可能出在以下几个方面:

    1. 命名空间问题: 仔细检查所有使用的命名空间是否正确,尤其关注trt, tt, tptz等ONVIF相关的命名空间。 确保它们与ONVIF标准文档中定义的一致。一个微小的错误,比如URL拼写错误或版本号不匹配,都会导致反序列化失败。 你提供的XML中命名空间看起来比较完整,但仍需仔细核对。

    2. 数据类型不匹配: 检查返回的数据类型是否与ONVIF WSDL文件中定义的类型相符。例如,DefaultPTZTimeout 应该是xsd:duration 类型,而不是你提供的100,这应该表示为 PT100S。 其他数值类型,例如 Quality, Bitrate, SampleRate 等也需要确认是否符合WSDL的定义,以及是否在合理的范围内。

    3. XML结构错误: 仔细检查XML的结构是否符合ONVIF规范。标签的嵌套关系、属性的使用、元素的顺序等都必须严格遵守标准。例如, <tt:Multicast /><tt:SessionTimeout />VideoEncoderConfigurationAudioEncoderConfiguration 中是空标签,这取决于你的具体实现,但需要确保符合标准和你的设备实际情况。 如果某些元素可选,但你的设备没有实现,则不应该包含这些空标签。

    4. 特殊字符: XML对某些特殊字符,例如<, >, &, ', " 有严格的规定。如果你的设备名称、位置等信息中包含这些字符,需要进行转义,例如使用&lt;, &gt;, &amp;, &apos;, &quot; 分别代替。 你提供的截图中显示的乱码 t的复消想王交行反米列化时出 很可能就是由于特殊字符未正确处理导致的。

    5. gSOAP版本兼容性: 你提到使用gSOAP 2.8。虽然gSOAP广泛用于ONVIF开发,但不同版本之间可能存在细微的差异。尝试更新到最新稳定版本的gSOAP,或者查找与你使用的ONVIF版本兼容的gSOAP版本。

    解决步骤:

    1. 使用XML验证工具: 将你的XML响应复制到在线XML验证工具或使用专门的XML验证库,检查是否存在语法错误或结构问题。

    2. 对比WSDL: 仔细对比你的XML响应与ONVIF对应的WSDL文件,确保每个元素的名称、命名空间、数据类型、出现次数都符合规范。 特别注意 trt:GetProfilesResponse 的定义。

    3. 简化测试: 创建一个最小的GetProfiles响应,只包含最基本的必要元素,例如ProfilesName, token等。 如果这个简化的响应能够被Onvif Device Manager成功解析,则逐步添加其他元素,直到找到导致问题的元素。

    4. 日志调试: 在你的设备端代码中添加详细的日志输出,记录GetProfiles请求和响应的完整内容,以便分析问题所在。

    5. Wireshark抓包: 使用Wireshark等网络抓包工具捕获设备与Onvif Device Manager之间的通信数据,分析GetProfiles请求和响应的原始数据,可以帮助你发现一些隐藏的问题。

    代码示例 (gSOAP):

    以下是一个gSOAP服务端处理GetProfiles请求的示例代码片段,仅供参考:

    int __tds__GetProfiles(struct soap *soap, 
                         struct _tds__GetProfiles *tds__GetProfiles, 
                         struct _tds__GetProfilesResponse *tds__GetProfilesResponse) {
      // 创建一个Profile
      tds__GetProfilesResponse->Profiles = soap_new_trt__Profile(soap, -1);
      tds__GetProfilesResponse->Profiles->Name = soap_new_std__string(soap, -1);
      *tds__GetProfilesResponse->Profiles->Name = "MainProfile";
      tds__GetProfilesResponse->Profiles->token = soap_new_std__string(soap, -1);
      *tds__GetProfilesResponse->Profiles->token = "MainProfileToken";
      tds__GetProfilesResponse->Profiles->fixed = soap_new_bool(soap, -1);
      *tds__GetProfilesResponse->Profiles->fixed = true;
    
      // ... 添加其他 Profile 元素,例如 VideoSourceConfiguration, VideoEncoderConfiguration 等 ...
    
      return SOAP_OK;
    }
    

    请仔细检查你的代码,确保生成的XML响应完全符合ONVIF规范。 通过以上步骤,你应该能够找到问题的原因并解决它。 如果问题仍然存在,请提供更详细的错误信息和相关代码片段,以便我能够提供更具体的帮助.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(10条)

报告相同问题?

问题事件

  • 系统已结题 12月19日
  • 已采纳回答 12月11日
  • 赞助了问题酬金15元 12月11日
  • 创建了问题 12月11日