4

I want to capture the log details of my Hikvision DVR. To capture the log HikVision provide the REST Web service in their RACM specification document. While hittin the service I am getting badXMLFormat Error in response.

Please find below detail description of the Issue.

Device Details :

Device Name : Embedded Net DVR Product Number : DS-7208HQHI-F1 Firmware Version : V3.4.80

service URL : http://myDVRStaticIPAddress/ISAPI/ContentMgmt/logSearch Method : POST

Input/Request Body

<?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> 

Response

<?xml version="1.0" encoding="UTF-8" ?>
<ResponseStatus version="1.0" xmlns="urn:psialliance-org">
    <requestURL>/ISAPI/ContentMgmt/logSearch</requestURL>
    <statusCode>5</statusCode>
    <statusString>Invalid XML Format</statusString>
    <subStatusCode>badXmlFormat</subStatusCode>
</ResponseStatus>

I am getting statusCode 5 for above service. It seems my input xml(CMSearchDescription) is not in proper format or not the updated one.

service Name : /ISAPI/ContentMgmt/logSearch

Any help on the issue will be greatly appreciated.

Thanks in advance.

Amit Sharma
  • 41
  • 1
  • 2

5 Answers5

1

I have this working on my test system, it required a few changes to your XML, as it wasn't correctly formatted. (a few of these were mentioned in previous comments)

  1. Ensure that you have the correct closing </timeSpan>, you've missed off the /
  2. Remove the spaces around the searchResultPosition and maxResults (it still works, but it's not correct)
  3. You have misspelt the opening tag of <endTIme>, it should be <endTime> without the capital I.
  4. Finally, the tag metaID should be metaId without the capital D

Also, I can't fully test your metaId tag, as I don't have any matches in that category.

This one log.std-cgi.com definitely pulls back all log entries, and this one log.std-cgi.com/Alarm returns all alarm entries.

Here's the full 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>
Rich S
  • 3,248
  • 3
  • 28
  • 49
0

Hikvision/Annke devices return the content type incorrectly.

You will see in the HTTP Response Headers the following:

Content-Type: application/xml; charset="UTF-8"

Notice the "UTF-8"

Your HTTP client is unable to determine the charset "UTF-8" with double quotes. If you can modify the response headers before your XML parser reads the content you should suffice. Change the header to Content-Type: application/xml; charset=utf-8

Double quote charsets are a part of the standard and are honored by most browsers.

Jeremy
  • 3,880
  • 3
  • 35
  • 42
0

A bit late.

  1. You're using < timeSpan > instead of < /timeSpan >
  2. Their documentation is incorrect, use RFC 2326 Absolute time representation for the dates (at least for xmlns="http://www.isapi.org/ver20/XMLSchema")

3.7 Absolute Time

 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
zeralight
  • 620
  • 1
  • 5
  • 19
0

If you have copy the Hikvision example you probably have an error on "endTime" string rewrite the endTime open and close tags, may be solve your problem.

it maybe late for you but interesting for other users.

0

How do I get the ID for my device:


I performed xml correction, but I'm getting this result:

    <?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>

--------- believe the ID is wrong, this is the documentation:------------

enter image description here

    <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>
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • Maybe ask this as separate question? It's unlikely to get a response when just added to a comment of an existing question. – Rich S Jan 12 '20 at 23:28