-1

I want to create an application to control camera parameters (users/ptz/get video). The camera is using the ONVIF protocol.

I am using Qt framework 5.13.

I found gsoap tool and .wsdl files from onfiv.com. Then i use guide from https://www.genivia.com/examples/onvif/index.html to create .h/.cpp files from devicemanagement.wsdl. I have generated one proxy class from devicemanagement.wsdl, and the program on Qt with generated files is working, but I need user authorization and ptz control...

How can I use gsoap, onvif specifications files(.wsdl) to generate class, which user authorization and ptz control for Qt?

Maybe someone makes the same application on Qt and can help me.

Sujay Ghosh
  • 2,828
  • 8
  • 30
  • 47
  • 1
    I recommend you [this project in GitHub](https://github.com/hummatli/onvif-qt-server-client) , that was `Onvif QT Server and Client` – Parisa.H.R Feb 07 '22 at 10:54
  • 1
    Please provide enough code so others can better understand or reproduce the problem. – Community Feb 18 '22 at 10:41

1 Answers1

1

Run wsdl2h on the ptz.wsdl:

wsdl2h -O4 -P -x -o onvif.h http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl

This assumes you have the typemap.dat file in the current directory with the ONVIF namespace bindings, see the ONVIF example to get that file.

Option -O4 aggressively "slices" the WSDL to reduce code size only to the necessary components, see article Schema Slicing Methods to Reduce Development Costs of WSDL-Based Web Services.

To generate C++ proxy classes:

soapcpp2 -C -j -2 -I gsoap/import onvif.h

The -C option specifies client-only, -j specifies proxy classes, -2 specifies SOAP 1.2 enforcement, -I is to import the necessary files.

If you need WS-Security authentication, then add the line:

#import "wsse.h"

to the onvif.h file if not already there, then rerun soapcpp2.

Compile:

c++ -O2 -I. -Igsoap/custom -o app soapPTZBindingProxy.cpp soapC.cpp dom.cpp stdsoap2.cpp wsseapi.c

Some source code files are generated, others are part of the gSOAP libraries.

The code generation tools have lots of options, so it depends a bit on what you want to accomplish.

If you want to use QT strings and types, then this can be done too with a modification of the typemap.dat file and by using the custom serializers located in gsoap/custom. For example, custom/qstring.h tells you to:

        To automate the wsdl2h-mapping of xsd:string to
        QString, add this line to the typemap.dat file:

        xsd__string = #import "custom/qstring.h" | xsd__string 

Then rerun wsdl2h to get the QT string binding. Compile custom/qtstring.cpp with your project.

Dr. Alex RE
  • 1,772
  • 1
  • 15
  • 23
  • 1
    I did similar to this but to create pure C++ ONVIF and did not know that the import with QString type also possible. Anyhow this is just the start of a long journey with ONVIF. The worst is with cameras not truly compliant and each defaulting to very unexpected values. – Alexander V Feb 07 '22 at 18:59
  • Hello! Thanks for answer :) @Dr. Alex RE I have question, when i will add **xsd_string** to _typemap.dat_, i will need to add qstring.h to gsoap/custom folder? – Payalnick Feb 08 '22 at 05:27
  • The gsoap/custom/qstring.h file is imported into the .h file for soapcpp2 (wsdl2h adds the import with the suggested typemap.dat addition) and gsoap/custom/qstring.cpp is compiled. The files are already included in the gsoap distro. – Dr. Alex RE Feb 08 '22 at 17:26
  • @Dr.Alex Re I followed your instructions, made two versions of the files: with QString and without them. When adding the generated files to the project and compiling the project, I got the following [errors](https://drive.google.com/file/d/11vfJlLT5xPLsgxfYKETJ8qFZcfkb-572/view?usp=sharing) (the same ones I got when I did according to the instructions from the site). What could be the reason? I added ws2_32 lib, ssl and crypto lib to the project. I also added the generated files [link](https://drive.google.com/file/d/1K_CSKX-VyN5bSS5KASzGu_f3Pz2MJjqE/view?usp=sharing) – Payalnick Feb 09 '22 at 06:26
  • I don't think you've #include'd the necessary files in your source code: #include "wsseapi.h", #include "soapPTZBindingProxy.h". There is also a xyz.nsmap file to include, the name of which depends on the WSDL. Do NOT #include the .h file generated by wsdl2h and do NOT include custom/qstring.h because those are soappcp2 files to generate code. – Dr. Alex RE Feb 10 '22 at 14:11