Coder Social home page Coder Social logo

onvif's Introduction

Java ONVIF (Open Network Video Interface Forum)

ONVIF is a community to standardize communication between IP-based security products (like cameras).

This project aims to improve https://github.com/milg0/onvif-java-lib.
I've tried to convice its author to use to my code but it seems we have different objectives: my goal is to create a project that focus on the funny part of the development of an ONVIF application, keeping the interaction with the WS as simple as possible and delege that annoying part to Apache CXF in order to not waste the developer time in writing (and MAINTAINING) code that interacts with ONVIF web services.
My wish is to help other developers willing to contribute to an enterprise-level Java library for ONVIF devices.

Apported improvements

  • Project mavenization and modularization (separation between Java stubs and application) and
  • WS client generation using Apache CXF maven plugin (declaring the specific Onvif specification of each wsdl)
  • maintainability and extendability of the overall code
  • Separation of Test/examples from other code

Rebuilding WS stubs

If you need to change the list of managed WSDLs (in onvif/onvif-ws-client/src/main/resources/wsdl) and thus you need to regenerate the WS Java stubs using the Apache CXF codegen maven plugin, you need to go through the following steps:

  1. Download Onvif WSDLs to onvif/onvif-ws-client/src/main/resources/wsdl appending the version before the .wsdl suffix. For example, from main dir (onvif) use you can run the following shell commmand:
    wget http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl onvif-ws-client/src/main/resources/wsdl/devicemgmt_2.5.wsdl
  2. Update WSDLLocations constants (if needed) within class de.onvif.utils.WSDLLocations (module onvif-java)
  3. Add required url-rewriting rules (if needed) to onvif/onvif-ws-client/src/main/resources/wsdl/jax-ws-catalog.xml
  4. Delete old Java classes in onvif/onvif-ws-client/src/main/java
  5. Run the class generation command: decomment goal and phase of cxf-codegen-plugin in onvif-ws-client pom.xml and run mvn clean install
  6. To see how to properly add a new ONVIF service to OnvifDevice look into OnvifDevice.init()

TODOS

My next goals are:

  1. Create an active community of enthusiastic developers (the crazier you are, the better)
  2. Write a more comprehensive examples (e.g. subscribe to an event notification, use I/O ports, etc...)
  3. Create consistent Onvif specifications tags (at least for onvif-ws-client). For example: 2.4, 2.5, etc...
  4. Fix WS-Discovery example (with my camera it doesn't work at all)
  5. Write a simple UI to test the device functionalities
  6. Fix offline mode (xml files in local folder)

onvif's People

Contributors

bhlowe avatar dependabot[bot] avatar fpompermaier avatar pinkcao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onvif's Issues

Java 11 support?

Did anyone get this to compile and run on newer versions of java? This is more of a generic "how to get javax.xml.soap, jaxb2 to run on java 11.. but hoping someone has a quick pointer..

I can add dependencies to get it to compile, but then run errors like:
Error: Unable to initialize main class org.onvif.client.SimpleTest
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/xml/soap/SOAPException

I'll try to answer my own question.. but thought I'd ask... Thanks!

No future dev?

Why is there no further dev happening here? Seems to have started off well - plus there's still no repo on Github!

Long return time when I initialize an Onvif device

Hello Flavio Pompermaier, i find it returns long time when i initialize an Onvif device. Specifically when I call this class de. onvif. soap When using the init() function in OnvifDevice, it is found that the return time is about 20 seconds.

XML Reader ERROR

hi developer,

I've cloned your project and I've done build install. after I run the program code as in the example, an error occurs. here is the error
`Exception in thread "main" com.sun.xml.internal.ws.streaming.XMLStreamReaderException: XML reader error: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '.' (code 46) in prolog; expe
cted '<'
at [row,col,system-id]: [1,1,"file:/D:/WAW/HARD/git/jse/testsuite/"]
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.wrapException(XMLStreamReaderUtil.java:311)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:84)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextContent(XMLStreamReaderUtil.java:154)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextElementContent(XMLStreamReaderUtil.java:89)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.hasWSDLDefinitions(RuntimeWSDLParser.java:310)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:217)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:194)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:163)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:348)
at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:306)
at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:215)
at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:196)
at com.sun.xml.internal.ws.client.WSServiceDelegate.(WSServiceDelegate.java:192)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.(Service.java:77)
at org.onvif.ver10.device.wsdl.DeviceService.(DeviceService.java:36)
at de.onvif.soap.OnvifDevice.init(OnvifDevice.java:147)
at de.onvif.soap.OnvifDevice.(OnvifDevice.java:91)
at len.scadajakpro.testsuite.NewOnvifLibTest.main(NewOnvifLibTest.java:13)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '.' (code 46) in prolog; expected '<'
at [row,col,system-id]: [1,1,"file:/D:/WAW/HARD/git/jse/testsuite/"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:647)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2054)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
at com.sun.xml.internal.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:81)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:65)
... 17 more

FAILURE: Build failed with an exception.`

and here's a sample code I created

public class NewOnvifLibTest { public static void main(String[] args) throws SOAPException, ConnectException { OnvifDevice device = new OnvifDevice("192.168.2.100", null, null); System.out.println("Device Info " + device.getDeviceInfo()); /* List<Profile> listProfile = device.getMedia().getProfiles(); for(int i=0; i<listProfile.size(); i++) { System.out.println("Profile 1 " + listProfile.get(i).getToken()); } */ } }

can you explain why the error occurred? and how to fix it?

jaxws uses ip, instead of DNS

Hi,

I am using this library, to try and connect to cameras, that are behind reverse proxies. However it seems somewhere in the code it changes the camera.localhost to the effective ip address (as in the ip of the camera, not how you connect to it), and that ip is unreachable. So the eg, I use the host https://camera.localhost, and I create an OnvifDevice, but it fails whenever I try and use a service, like media or ptz, since it somehow resolves to a.b.c.d/onvif/media_service, but this I cannot reach (reverse proxy).

Is there a way to trigger all services of Onvif device to keep using the dns instead of the ip of the interface where the camera runs?

current status

Dear developers

Just cloned your repo for a quick evaluation.
But I cound not found any example of how to connect to a camera.
can you give me a hint where I can find an example to connect to an ptz camera.

Thanks

SimpleSecurityHandler example usage?

Looking at the source code, it appears that the OnvifDevice doesn't properly use the username and password for the camera. Do you have an example of wiring in the SimpleSecurityHandler?

Also, the exception thrown when the camera returns 401 Unauthorized is also really unclear-- the exception simply says "org.apache.cxf.interceptor.Fault: Could not send Message." A better exception message would be the HTTPException...

Information abaut libary

Hi,
This library supports only client side? Or also server side?

I want to make virtual onvif device (software simulator), which will support profile S.
So I'm wondering if this is possible with this code.

Which developing environment are you using? IDE?

CreatePullPointSubscription

I am playing with your example (WsNotificationTest) about the capability to register to the events generated by the camera. I am was not able to create a pull point subscription, I suppose, for a malformed request. Playing with soapUI I found that using a request like the one generated by the stubs into the library generate an error of type "failed to parse topic expression", If I try to manually change the SOAP request it seems to work. Here follow the two requests:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
	<soap:Header>
		<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="true"><wsse:UsernameToken wsu:Id="UsernameToken-fb13b6a5-d87b-4662-92fd-5b4abefbe264"><wsse:Username>onvifadmin</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">e+HhUWCDpzfUdMX4k0b9gwMH3RM=</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">cFSFXKKlQ92SjSxV1LciFA==</wsse:Nonce><wsu:Created>2018-06-11T14:12:32.729Z</wsu:Created></wsse:UsernameToken></wsse:Security>
	</soap:Header>
	<soap:Body>
		<ns2:CreatePullPointSubscription xmlns:ns10="http://www.onvif.org/ver10/device/wsdl" xmlns:ns11="http://www.w3.org/2004/08/xop/include" xmlns:ns12="http://docs.oasis-open.org/wsrf/r-2" xmlns:ns2="http://www.onvif.org/ver10/events/wsdl" xmlns:ns3="http://docs.oasis-open.org/wsn/b-2" xmlns:ns4="http://docs.oasis-open.org/wsn/t-1" xmlns:ns5="http://www.w3.org/2005/08/addressing" xmlns:ns6="http://docs.oasis-open.org/wsrf/bf-2" xmlns:ns7="http://www.onvif.org/ver10/schema" xmlns:ns9="http://www.onvif.org/ver10/deviceIO/wsdl" xmlns:xmime="http://www.w3.org/2005/05/xmlmime">
			<ns2:Filter><ns3:TopicExpression Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet">tns1:Device//.</ns3:TopicExpression></ns2:Filter>
			<ns3:InitialTerminationTime>PT10S</ns3:InitialTerminationTime><ns2:SubscriptionPolicy/>
		</ns2:CreatePullPointSubscription>
	</soap:Body>
</soap:Envelope>

This generates a failure:

<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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:c14n="http://www.w3.org/2001/10/xml-exc-c14n#" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsa5="http://www.w3.org/2005/08/addressing" xmlns:wsrfbf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:wstop="http://docs.oasis-open.org/wsn/t-1" xmlns:tt="http://www.onvif.org/ver10/schema" xmlns:wsrfr="http://docs.oasis-open.org/wsrf/r-2" xmlns:tev1="http://www.onvif.org/ver10/events/wsdl/NotificationProducerBinding" xmlns:tev2="http://www.onvif.org/ver10/events/wsdl/EventBinding" xmlns:tev3="http://www.onvif.org/ver10/events/wsdl/SubscriptionManagerBinding" xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:tev4="http://www.onvif.org/ver10/events/wsdl/PullPointSubscriptionBinding" xmlns:tev="http://www.onvif.org/ver10/events/wsdl" xmlns:tns1="http://www.onvif.org/ver10/topics" xmlns:tnsaxis="http://www.axis.com/2009/event/topics" xmlns:ter="http://www.onvif.org/ver10/error">
   <SOAP-ENV:Header>
      <wsa5:To SOAP-ENV:mustUnderstand="true">http://www.w3.org/2005/08/addressing/anonymous</wsa5:To>
      <wsa5:Action SOAP-ENV:mustUnderstand="true">http://www.w3.org/2005/08/addressing/soap/fault</wsa5:Action>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <SOAP-ENV:Code>
            <SOAP-ENV:Value>SOAP-ENV:Sender</SOAP-ENV:Value>
         </SOAP-ENV:Code>
         <SOAP-ENV:Reason>
            <SOAP-ENV:Text xml:lang="en">failed to parse topic expression 'tns1:Device//.'</SOAP-ENV:Text>
         </SOAP-ENV:Reason>
         <SOAP-ENV:Detail>
            <wsnt:InvalidTopicExpressionFault>
               <wsrfbf:Timestamp>2018-06-11T16:15:39Z</wsrfbf:Timestamp>
            </wsnt:InvalidTopicExpressionFault>
         </SOAP-ENV:Detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This one instead seems to work:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:wsdl="http://www.onvif.org/ver10/events/wsdl">
   <soap:Header>
      <wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsse:UsernameToken wsu:Id="UsernameToken-595B90767A0CA82C1615284734003533">
            <wsse:Username>onvifadmin</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">rQsU/rVV74SYCLgDlzX3rcAwN+k=</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">nqmOvRNzRbojZPjBCQUhrA==</wsse:Nonce>
            <wsu:Created>2018-06-08T15:56:40.352Z</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>
   </soap:Header>
   <soap:Body>
      <wsdl:CreatePullPointSubscription>
         <!--Optional:-->
         <wsdl:Filter Dialect="http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet">tns1:Device//.</wsdl:Filter>
         <!--Optional:-->
         <wsdl:InitialTerminationTime>PT10S</wsdl:InitialTerminationTime>
         <!--Optional:-->
         <wsdl:SubscriptionPolicy>
            <!--You may enter ANY elements at this point-->
         </wsdl:SubscriptionPolicy>
         <!--You may enter ANY elements at this point-->
      </wsdl:CreatePullPointSubscription>
   </soap:Body>
</soap:Envelope>

Have you got any news or idea about it?

I need to read the actual pan and tilt position of the encoder so I am assuming that the events subscription is the proper way to go, but I am not sure of this. Do you have any hints about it?

Building original project with no change --> failed

Hi,
Thanks for this work, but to contribute, first I need to succeed in building your original version.
If I do so, Maven fail to build.
onvif is SUCCESS
onvif-ws-client is also SUCCESS
but
onvif-java FAILED with this error :
....blablabla...../onvif-java/src/test/java/org/onvif/client/GetTestDevice.java:[91,19] no suitable constructor found for Scanner(java.io.InputStream,java.nio.charset.Charset)

I followed instructions on readme.md without changing any list of managed WSDLs.

my maven --version is :

Apache Maven 3.6.3** (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /apache-maven-3.6.3
Java version: 1.8.0_163, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.1", arch: "x86_64", family: "mac"

The project still alive ?

Thanks for any help.

Is it incompatible with ONVIF protocol device version 2.20?

Hello, I am trying to use your library to obtain the playback data of the ONVIF protocol NVR device, but I have been unable to connect. I used your library to operate the PTZ without any problems before. Maybe it is a version problem. ? The ONVIF version of NVR is 2.20

w3.org dropping of HTTP in favour of HTTPS support causes failure

Hi

I've been using the Onvif library successfully in my CCTV NVR for just over a year. For a couple of days last week, the Onvif discovery was failing. This was due to w3.org testing a planned dropping of support for http requests, which they would send a 301 (or similar) redirect to an https url. The problem is that my cameras use http urls for the schemas and the Onvif library does not redirect by default. Is there a way it can configured to follow redirects?

w3.org are planning to make this change permanent in the near future which would stop Onvif discovery working altogether.

Thanks in advance

Rebuilding ws stubs

I've been trying to find an answer for this stackoverflow question. Since you've worked on building the stubs, could you help me out - I'd preferably like to do it using wsimport, without the Apache CXF plugin.

Thanks!

Please, provide the examples

Hello! You have done a great job, but it need of some examples for modern devices, like Axis cameras or other.
I tried use Main class from onfif-java package, but application crush with error

javax.xml.ws.soap.SOAPFaultException: MustUnderstand headers:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Security] are not understood

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.