The following is a sample ONVIF XML Payload that is sent to a camera to subscribe to Onvif Events (Such as Motion Detection)
Note the wsa:TO: Field which contains the camera IP Address, ONVIF Port and the onvif URL
In the example below, the Camera's IP Address and Onvif Port is 192.168.1.88 - Port 5000
And the URL used to post the XML Soap command is "/onvif/device_service"
This will be different for each camera, Which usually can be obtained using WS-Discovery
By sending SSDP Queries on the multicast address of 129.155.255.250 (Port 3702),
Or by using an existing Onvif Client, and Obtaining the Cameras IP Address, its Onvif Port, and URL end Point for Device Service(s)
Also note the wsa:Address which is the URL which the camera will POST XML data regarding the Onvif event
In the example below, the address is 192.168.1.1 Port 80.
The camera will use the url_to_call_on_event.php to POST the XML response when ANY Onvif event occurs.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2">
<SOAP-ENV:Header>
<wsa:Action>http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeRequest</wsa:Action>
<wsa:To>http://192.168.1.88:5000/onvif/device_service</wsa:To>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<wsnt:Subscribe>
<wsnt:ConsumerReference>
<wsa:Address>http://192.168.1.1:80/url_to_call_on_event.php</wsa:Address>
</wsnt:ConsumerReference>
<wsnt:InitialTerminationTime>PT1M</wsnt:InitialTerminationTime>
</wsnt:Subscribe>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>