给出无效XML格式的海康威视日志搜索REST API(POST方法)

给出无效XML格式的海康威视日志搜索REST API(POST方法),xml,rest,Xml,Rest,我想捕获我的海康威视DVR的日志详细信息。为了捕获日志,海康威视在其RACM规范文档中提供REST Web服务。 在点击服务时,我收到badXMLFormat错误响应 请查看以下问题的详细说明 设备详细信息: 设备名称:嵌入式网络DVR 产品编号:DS-7208HQHI-F1 固件版本:V3.4.80 服务URL: 方法:邮寄 输入/请求机构 {812F04E0-4089-11A3-9A0C-0305E82C2906} 2013-06-10T12:00:00Z 2013-06-10T13:30

我想捕获我的海康威视DVR的日志详细信息。为了捕获日志,海康威视在其RACM规范文档中提供REST Web服务。 在点击服务时,我收到badXMLFormat错误响应

请查看以下问题的详细说明

设备详细信息: 设备名称:嵌入式网络DVR 产品编号:
DS-7208HQHI-F1
固件版本:
V3.4.80

服务URL: 方法:邮寄

输入/请求机构

{812F04E0-4089-11A3-9A0C-0305E82C2906}
2013-06-10T12:00:00Z
2013-06-10T13:30:00Z
log.hikvision.com/Alarm/motionstart
20
40
回应

/ISAPI/ContentMgmt/logSearch
5.
无效的XML格式
badXmlFormat
我得到上述服务的状态码
5
。似乎我的输入xml(CMSearchDescription)的格式不正确,或者不是更新的格式

服务名称:/ISAPI/ContentMgmt/logSearch

在此问题上的任何帮助都将不胜感激


提前感谢。

海康威视/Annke设备返回的内容类型不正确

您将在HTTP响应头中看到以下内容:

内容类型:应用程序/xml;charset=“UTF-8”

请注意“UTF-8”

您的HTTP客户端无法使用双引号确定字符集“UTF-8”。如果您可以在XML解析器读取内容之前修改响应头,那么就足够了。将标题更改为
内容类型:application/xml;字符集=utf-8

双引号字符集是标准的一部分,并且受到大多数浏览器的尊重。

有点晚了

  • 您使用的是而不是
  • 他们的文档不正确,请使用RFC 2326绝对时间表示法表示日期(至少对于
    xmlns=”http://www.isapi.org/ver20/XMLSchema“
  • 3.7绝对时间

     Absolute time is expressed as ISO 8601 timestamps, using UTC (GMT).
     Fractions of a second may be indicated.
    
     utc-range    =   "clock" "=" utc-time "-" [ utc-time ]
     utc-time     =   utc-date "T" utc-time "Z"
     utc-date     =   8DIGIT                    ; < YYYYMMDD >
     utc-time     =   6DIGIT [ "." fraction ]   ; < HHMMSS.fraction >
    
     Example for November 8, 1996 at 14h37 and 20 and a quarter seconds
     UTC:
    
     19961108T143720.25Z
    
    绝对时间用UTC(GMT)表示为ISO 8601时间戳。
    可以指示秒的分数。
    utc range=“clock”“=”utc时间“-”[utc时间]
    utc时间=utc日期“T”utc时间“Z”
    utc日期=8位数;
    utc时间=6位数[“”分数];
    以1996年11月8日14时37分和20分之一秒为例
    UTC:
    19961108T143720.25Z
    

    如果您复制了海康威视示例,您可能在“endTime”字符串上出现错误,请重写endTime打开和关闭标记,这可能会解决您的问题


    它可能对您来说很晚了,但对其他用户来说很有趣。

    我的测试系统正在使用它,它需要对您的XML进行一些更改,因为它的格式不正确。(在以前的评论中提到了其中一些)

  • 确保您有正确的结束语,您错过了结束语
  • 删除searchResultPosition和maxResults周围的空格(它仍然有效,但不正确)
  • 您拼错了
    的开头标记,它应该是
    ,没有大写字母
    I
  • 最后,标签
    metaID
    应该是
    metaID
    ,不带大写字母
    D
  • 此外,我无法完全测试您的metaId标记,因为我在该类别中没有任何匹配项

    这一个
    log.std cgi.com
    肯定会收回所有日志条目,而这一个
    log.std cgi.com/Alarm
    会返回所有报警条目

    下面是完整的Xml

    <?xml version='1.0' encoding='UTF-8'?>
    <CMSearchDescription version='1.0' xmlns='http://www.isapi.org/ver20/XMLSchema'>
        <searchID>{812F04E0-4089-11A3-9A0C-0305E82C2906}</searchID>
        <timeSpanList>
            <timeSpan>
                <startTime>2013-06-10T12:00:00Z</startTime>
                <endTime>2013-06-10T13:30:00Z</endTime>
            </timeSpan>
        </timeSpanList>
        <metaId>log.hikvision.com/Alarm/motionstart</metaId>
        <searchResultPostion>20</searchResultPostion>
        <maxResults>40</maxResults>
    </CMSearchDescription>
    
    
    {812F04E0-4089-11A3-9A0C-0305E82C2906}
    2013-06-10T12:00:00Z
    2013-06-10T13:30:00Z
    log.hikvision.com/Alarm/motionstart
    20
    40
    
    如何获取设备的ID:


    我执行了xml更正,但得到了以下结果:

        <?xml version="1.0" encoding="UTF-8"?>
        <CMSearchResult version="2.0" 
        xmlns="http://www.hikvision.com/ver20/XMLSchema">
            <searchID>{{Abc12345}}</searchID>
            <responseStatus>true</responseStatus>
            <responseStatusStrg>NO MATCHES</responseStatusStrg>
            <numOfMatches>0</numOfMatches>
            <matchList>
        </matchList>
        </CMSearchResult>
    
    
    {{Abc12345}
    真的
    没有火柴
    0
    
    ---------请相信ID是错误的,以下是文档:------------

    
    
    我刚刚尝试了您的解决方案,我确认它有效。谢谢你,先生!也许可以单独问这个问题?如果只是添加到对现有问题的评论中,则不太可能得到回应。
    <?xml version='1.0' encoding='UTF-8'?>
    <CMSearchDescription version='1.0' xmlns='http://www.isapi.org/ver20/XMLSchema'>
        <searchID>{812F04E0-4089-11A3-9A0C-0305E82C2906}</searchID>
        <timeSpanList>
            <timeSpan>
                <startTime>2013-06-10T12:00:00Z</startTime>
                <endTime>2013-06-10T13:30:00Z</endTime>
            </timeSpan>
        </timeSpanList>
        <metaId>log.hikvision.com/Alarm/motionstart</metaId>
        <searchResultPostion>20</searchResultPostion>
        <maxResults>40</maxResults>
    </CMSearchDescription>
    
        <?xml version="1.0" encoding="UTF-8"?>
        <CMSearchResult version="2.0" 
        xmlns="http://www.hikvision.com/ver20/XMLSchema">
            <searchID>{{Abc12345}}</searchID>
            <responseStatus>true</responseStatus>
            <responseStatusStrg>NO MATCHES</responseStatusStrg>
            <numOfMatches>0</numOfMatches>
            <matchList>
        </matchList>
        </CMSearchResult>
    
        <CMSearchDescription version="1.0" xmlns=" http://www.std- 
        cgi.org/ver20/XMLSchema">
        <searchID><!-- req, xs: uuid --></searchID>
        <timeSpanList>
        <timeSpan>
        <startTime><!-- req, xs:time, ISO8601 time --></startTime>
        <endTIme><!-- req, xs:time, ISO8601 time --></endTime>
        <timeSpan>
        </timeSpanList>
        <metadataList>
        <metadata>
        <metadataDescriptor><!-- req, xs:string --></metadataDescriptor>
        <SearchProperity>
        <plateSearchMask><!-- opt, xs:string,1-31 --></plateSearchMask>
        <stateOrProvince><!-- opt, xs:interger --></stateOrProvince>
        <nation> <!-- opt, xs:string,”EU,ER” --> </nation>
        </SearchProperity>
        </metadata>
        </metadataList>
        <searchResultPosition> <!-- opt, xs: interger --> 
        </searchResultPosition>
        <maxResults><!-- opt, xs: interger --></maxResults>
        </CMSearchDescription>