I'm developing an application that will probe ONVIF devices attached on network for auto-discovery. According to ONVIF Core specification SOAP format of Probe message is :
<?xml version="1.0" encoding="UTF-8"?>
<e:Envelope xmlns:e="http://www.w3.org/2003/05/soap-envelope"
xmlns:w="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
xmlns:dn="http://www.onvif.org/ver10/network/wsdl">
<e:Header>
<w:MessageID>uuid:84ede3de-7dec-11d0-c360-f01234567890</w:MessageID>
<w:To e:mustUnderstand="true">urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To>
<w:Action
a:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/Pr
obe</w:Action>
</e:Header>
<e:Body>
<d:Probe>
<d:Types>dn:NetworkVideoTransmitter</d:Types>
</d:Probe>
</e:Body>
</e:Envelope>
How can i send this message in WCF to discover onvif deivce?
ONVIF Devices are discovered according WS-Discovery specification. You send a Probe message, and devices that match the Probe's constraints send back a ProbeMatch message, as described on page 13 and 14 in ONVIF Application Programmers Guide.
The easiest and the most reliable would be to just ask the camera's manufacturer or seller. Contact their customer care service, let them know the camera's model and firmware version, and ask if the ONVIF is supported in your camera.
Launch Onvif Device Manager, the device list will automatically show the devices that are compatible with Onvif. If you haven't found your devices, please click "Add" at the left end corner and input your IP address to add your cameras. Step 3. Input the name and password of your device to log in.
Just use the WCF web service discovery features. ONVIF follows the same standard as that implemented by WCF. You'll need to use the DiscoveryClient class to send the probe.
It's been a while since I've done it so it might not be exactly right but your code should look something like the following. The multicast probe will find all discoverable devices. You can detect if your onvif device has responded by inspecting the metadata for each response in the event handler. If you're still unable to get a response its probably a network or device issue. If you do get a response you can refine your find criteria to only notify of required types.
class Program
{
static void Main(string[] args)
{
var endPoint = new UdpDiscoveryEndpoint( DiscoveryVersion.WSDiscoveryApril2005 );
var discoveryClient = new DiscoveryClient(endPoint);
discoveryClient.FindProgressChanged += discoveryClient_FindProgressChanged;
FindCriteria findCriteria = new FindCriteria();
findCriteria.Duration = TimeSpan.MaxValue;
findCriteria.MaxResults = int.MaxValue;
// Edit: optionally specify contract type, ONVIF v1.0
findCriteria.ContractTypeNames.Add(new XmlQualifiedName("NetworkVideoTransmitter",
"http://www.onvif.org/ver10/network/wsdl"));
discoveryClient.FindAsync(findCriteria);
Console.ReadKey();
}
static void discoveryClient_FindProgressChanged(object sender, FindProgressChangedEventArgs e)
{
//Check endpoint metadata here for required types.
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With