onvif icon indicating copy to clipboard operation
onvif copied to clipboard

Add action string to Content-Type in ONVIF HTTP Request Header

Open RogerHardiman opened this issue 3 years ago • 3 comments

It looks like SOAP 1.2 requires ths field and 1 ONVIF camera requires it The code is not very efficient. It parses the XML to be sent to generate the action string. It would be better for action strings to be hard coded throughout the library

RogerHardiman avatar Mar 01 '22 00:03 RogerHardiman

Andrew, Chris, could you take a look at this change please.

The SOAP standard allows you to pass the API function in a HTTP header as well as it being part of the XML payload. Eg the HTTP Header includes action="http://www.onvif.org/onvif/ptz/ContinuousMove" or actopn="http://www.onvif.org/onvif/device/GetCapabilities"

The idea is that a XML SOAP server could read the HTTP header and then decide which worker service to pass the XML to without having to parse the entire XML payload and evaluating the namespaces.

In my ONVIF Server projects I see action="..." coming in from lots of VMS systems and from ODM too. But this library does not generate them.

So far all cameras we have used have ignored the lack of action="..." string in the HTTP header. But now I have a camera that requires it.

So we need to add action="..." to the http header of every ONVIF request. So this code computes the action="..." header by parsing the XML we are about to send out. That means it is not very efficient but it does mean that it will work all the time. But I've left the ability in the code for us to hard code action strings in each ONVIF function if we wanted to remove a tiny bit of CPU usage. For me, I'd probably do that in the PTZ commands as they are the ones where you can have a lot of ONVIF messages. For everything else, a few CPU cycles more on each ONVIF command will not make any difference.

So let me know if you think the code is OK and I'll merge into master

RogerHardiman avatar Mar 10 '22 08:03 RogerHardiman

@RogerHardiman Hello! I think that everything is ok! I've just point out some syntax questions in the review, they are not mandatory at all

agsh avatar Mar 14 '22 01:03 agsh

And again and again :smile: I'm looking for the node.js jobs with relocation from Russia :laughing: My LinkedIn: https://www.linkedin.com/in/laptev/

agsh avatar Mar 14 '22 01:03 agsh

Hi @agsh. I've made the suggested changes for adding the HTTP Header. I see this PR has also picked up recent changes to PTZSpaces and RelativePTZ commands which I'm using on a project.

RogerHardiman avatar Oct 25 '22 17:10 RogerHardiman

@RogerHardiman Hello! Great PR, thanks a lot! I'm waiting for your merge to master :) I'll also make the changes in HTTP headers and PTZ commands in new version here: https://github.com/agsh/onvif/blob/v1/src/onvif.ts#L276 https://github.com/agsh/onvif/blob/v1/src/ptz.ts#L373

agsh avatar Oct 26 '22 07:10 agsh