Question

I am new to media streaming.
One of the modules in my project includes live streaming from ONVIF devices. I have found several tutorials regarding ONVIF live streaming. I downloaded the wsdl files from the onvif official site.And generated source code from wsdl(i'm using netbeans IDE).
And configured the onvif device. Now I have an IPAddress of the onvif device and the generated WS.
I am very confused about the integration of this ws with device.
How can I connect to the device using these WS?

The code have tried is given below

URL url = new URL("file://"+System.getProperty("user.home")+"/Desktop/devicemgmt.wsdl");

Service service = Service.create(url, qname);
Device device = service.getPort(Device.class);
System.out.println("device : "+device);

((BindingProvider) device).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                "http://" + camIp + "/onvif/device_service");

Holder<String> manufacturer = new Holder<String>();
Holder<String> model = new Holder<String>();
Holder<String> firmwareVersion = new Holder<String>();
Holder<String> serialNumber = new Holder<String>();
Holder<String> hardwareId = new Holder<String>();

device.getDeviceInformation(manufacturer, model, firmwareVersion, serialNumber, hardwareId);

When trying to run, the given exception occurs

run:device : Metro/2.2.0-1 (tags/2.2.0u1-7139; 2012-06-02T10:55:19+0000) JAXWS-RI/2.2.6-2 JAXWS/2.2 svn-revision#unknown: Stub for http://192.168.2.22/onvif/device_service
Exception in thread "main" com.sun.xml.ws.protocol.soap.VersionMismatchException: Couldn't create SOAP message. Expecting Envelope in namespace http://www.w3.org/2003/05/soap-envelope, but got http://schemas.xmlsoap.org/soap/envelope/ 
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:198)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:328)
    at com.sun.xml.ws.encoding.StreamSOAP12Codec.decode(StreamSOAP12Codec.java:102)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:149)
    at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:361)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:279)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:228)
    at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
    at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:139)
    at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:961)
    at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:910)
    at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:873)
    at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:775)
    at com.sun.xml.ws.client.Stub.process(Stub.java:429)
    at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:168)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
    at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:102)
    at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:151)
    at com.sun.proxy.$Proxy44.getDeviceInformation(Unknown Source)
    at devicetest.OnvifTest.main(OnvifTest.java:52)
Java Result: 1
BUILD SUCCESSFUL (total time: 17 seconds)
            System.out.println(manufacturer.value);
            System.out.println(model.value);
            System.out.println(firmwareVersion.value);
            System.out.println(serialNumber.value);
            System.out.println(hardwareId.value);

Thanks for any suggestion.

Was it helpful?

Solution

Thanks to all. Finally I found a solution. The error was due to the version mismatch b/w my device and soap version. I resolved the issue by changing the schema envelope url in the wsdl.

OTHER TIPS

I think we need more information on what you have tried. Since the question is vague, having a look into this may help. This explains the way to connect to the device using WS. http://www.openipcam.com/files/ONVIF/ONVIF_WG-APG-Application_Programmer's_Guide.pdf

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top