How to get device information using Onvif library c#?

Azeem Akram picture Azeem Akram · May 29, 2012 · Viewed 12.8k times · Source

I am making a c# windows application which collects the devices connected to my network using an open source library Onvif.

i am doing in this way.

    ServicePointManager.Expect100Continue = false;
    var endPointAddress = new EndpointAddress("http://ip_address:port/onvif/device_service");
    var httpBinding = new HttpTransportBindingElement();            
    var bind = new CustomBinding(httpBinding);
    var temp = new DeviceClient(bind, endPointAddress);
    var request = new GetDeviceInformationRequest();
    var response = temp.GetDeviceInformation(request); ////// Error Here described bellow
    string firm = response.FirmwareVersion;
    string manu = response.Manufacturer;
    string serial = response.SerialNumber;
    string model = response.Model;

Error Message :: There was no endpoint listening at http:// something:port/onvif/device_service that could accept the message.this is often caused by an incorrect address or SOAP action

can any one help me?

I think i am not making proper connection with the server, is it so? if so then how to resolve it?

Answer

chirrin dul ari picture chirrin dul ari · May 30, 2012

Maybe the WS-DISCOVERY gives you extra information. I would try not to use any port after the IP of the camera.

When the test sends an UDP to the multicast address 239.255.255.250, port 3702 (WS-Discovery), this is the camera's answer:

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:wsa="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">
  <SOAP-ENV:Header>
    <wsa:MessageID>uuid:cb3dea50-aa60-11e1-88b9-00408cb972aa</wsa:MessageID>
    <wsa:RelatesTo>uuid:5bca11ff-61b8-4d07-8a26-90274ad51db8</wsa:RelatesTo>
    <wsa:To SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    <wsa:Action SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action>
    <d:AppSequence SOAP-ENV:mustUnderstand="true" MessageNumber="1" InstanceId="1338367479"></d:AppSequence>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <d:ProbeMatches>
      <d:ProbeMatch>
        <wsa:EndpointReference>
          <wsa:Address>urn:uuid:65a142fc-a41e-11e1-9cc8-00408cb972aa</wsa:Address>
        </wsa:EndpointReference>
        <d:Types>dn:NetworkVideoTransmitter</d:Types>
        <d:Scopes>
            onvif://www.onvif.org/type/video_encoder 
            onvif://www.onvif.org/type/ptz 
            onvif://www.onvif.org/hardware/P5534-E 
            onvif://www.onvif.org/name/AXIS%20P5534-E 
            onvif://www.onvif.org/location/ 
        </d:Scopes>
        <d:XAddrs>
            h##p://zeroconfIP/onvif/device_service 
            h##p://unicastIP/onvif/device_service
        </d:XAddrs>
        <d:MetadataVersion>1</d:MetadataVersion>
      </d:ProbeMatch>
    </d:ProbeMatches>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Try to discover the response and see if any XAddrs is not the default you expect.