Script to generate the onvif's Makefile to generate the c++ client proxies code with gsoap (wsdhl2h and soapcpp2) based on the wsdl url in wsdl.txt file. This script are able to generate the environment for onvif's applications.
-
generate a Makefile based on wsdl.txt file with the url for the onvif wsdl specifications;
-
Makefile will generate all modules with c++ namespaces and separeted in folders;
-
autofix the gsoap code for c++ namespaces. The original code does not compile with c++ namespaces and onvif specifications.
-
gsoap
-
pcregrep
( illustrative url )
$ git clone onvif-mkmakefile.git
$ mv onvif-mkmakefile .make
$ ./make/mkmakefile.sh > Makefile
$ make secenv devicemgmt/devicemgmt.hpp ptz/ptz.hpp
$ cd devicemgmt
$ g++ -c -DWITH_NOIDREF *.cpp
$ cd ../ptz
$ g++ -c -DWITH_NOIDREF *.cpp
- compile
secenv/*.cpp
$ cd ../secenv
$ g++ -c *.cpp
- The duration.c and stdsoap2.cpp file must have the same version of your executables soapcpp2 and wsdl2h
- Change the file of the
#include
directive from soapH.h to DevicemgmtH.h or any module header in the duration.c file; - Compile the duration.c
$ mv duration.c devicemgmt
$ g++ -c devicemgmt/duration.c
g++ -c -DWITH_NONAMESPACES stdsoap2.cpp
e.g. This program will request the DeviceInformation Method:
#include <iostream>
#include "devicemgmt/devicemgmt.hpp"
#include "ptz/ptz.hpp"
using namespace std;
#define URL "http://169.254.1.20/onvif/services"
int main(){
// create and inicialize soap context
struct soap soap_context;
soap_init(&soap_context);
// class proxy
Devicemgmt::DeviceBindingProxy device(&soap_context);
Ptz::PTZBindingProxy ptx(&soap_context);
// set namespaces after PTZBindgProxy inicialization
soap_set_namespaces(&soap_context, Devicemgmt_namespaces);
Devicemgmt::_tds__GetDeviceInformation device_request;
Devicemgmt::_tds__GetDeviceInformationResponse device_response;
std::string endpoint = URL;
int result = SOAP_ERR;
result = device.GetDeviceInformation( endpoint.c_str(), NULL,
&device_request, device_response );
if ( result == SOAP_OK )
{
std::cout << "Mfr: " << device_response.Manufacturer << std::endl;
std::cout << "Model: " << device_response.Model << std::endl;
std::cout << "F/W version: " << device_response.FirmwareVersion << std::endl;
std::cout << "HardwareId: " << device_response.HardwareId << std::endl;
std::cout << "Serial number:" << device_response.SerialNumber << std::endl;
}else{
std::cout << "ERROOO" << std::endl;
std::cout << result << std::endl;
}
soap_destroy(&soap_context); // remove deserialized class instances (C++ only)
soap_end(&soap_context); // clean up and remove deserialized data
soap_done(&soap_context); // detach context (last use and no longer in scope)
return 0;
}
$ g++ main.cpp devicemgmt/*.o ptz/*.o duration.o secenv/secenvC.o stdsoap2.o -o getDeviceInformation