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.
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…