255 def msg = parseLanMessage(description)
256 def body = new XmlSlurper().parseText(new String(msg.body))
However, it turns out some newer cameras don't send the XML in this way and I get an error:
org.xml.sax.SAXParseException: Content is not allowed in prolog. on line 256 (method parse)
Comparing the old and new cameras. I noticed the older camera sends POSTs with content-type application/xml; charset="UTF-8" and the XML is in the body of the message.
On newer cameras, it sends POSTs with content-type multipart/form-data; boundary=boundary and the XML looks like a file.
How can I handle this scenario? Thanks for any tips in the right direction.
If it is coming in as form data itβs probably in a pair:value format , possibly JSON. If you temporarily remove the parser and just print the raw data what does it look like?
Anyone figure this out? Im trying to make a custom Hikvision listening DH and hung up on how to receive and parse out the events from the various cameras. I know there's a built in Hikvision driver but I have some different needs and that code(the parts I need) is not publicly available for me to "borrow".
@kleung1 , @kampto
Hey guys... hot off the presses... I've got a solution for you with regards to the multi-part alert messages sent by newer Hikvision cameras. It's easy and it works. Came up with it over the weekend and been testing with it all morning.
Just wanted to share this utility I came across from Dahua called Network Assistant that lets you open up an http listener on your windows pc to receive alarms from your cameras and inspect the contents. There are other choices for http debugging and app development but this one is super easy to use if all you want is the basics. I found it being used in this Hikvision doc that comes off the EU portal, which is the place to go for Hikvision doc, "How to get real-time alarm/event in HTTP listening mode"
Yeah, can see that @TomS 's driver does not include the import... And can now see that row 127 includes a static field reference. Can only assume use of the field must produce the error, which may not have happened in all situations.