博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
生成onvif相关的开发代码
阅读量:4040 次
发布时间:2019-05-24

本文共 6520 字,大约阅读时间需要 21 分钟。

一、必备网址
1. Onvif官网:

2. gsoap官网:

二、操作步骤

1. 下载gsoap

在gsoap官网旁边,有sourceforge的链接,去那里下源码。

2、在centos下编译gsoap

编译gsoap需要相关环境:

yum install byacc -y

yum install flex -y

yum install openssl-devel -y

yum install zlib-dev -y
yum install bison-devel -y
yum install zlib-devel -y

然后输入:

./configure --prefix=安装路径

make

make install

至此,安装gsoap完成。

三、生成onvif头文件

进入gsoap的安装目录下的bin中,找到名为wsdl2h的可执行文件。用该可执行文件生成onvif.h头文件有2种方式,在线方式和离线方式。输入:wsdl2h  -h查看帮助

1.在线方式:

 ./wsdl2h -c -s -t typemap.dat -o onvif.h http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl http://www.onvif.org/onvif/ver10/events/wsdl/event.wsdl http://www.onvif.org/onvif/ver10/deviceio.wsdl http://www.onvif.org/onvif/ver20/imaging/wsdl/imaging.wsdl http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl http://www.onvif.org/onvif/ver10/search.wsdl http://www.onvif.org/onvif/ver10/receiver.wsdl http://www.onvif.org/onvif/ver10/recording.wsdl http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl 

每个链接用空格分隔开。

2.离线方式:

先下载好相关wsdl文件,如remotediscovery.wsdl devicemgmt.wsdl,放到目录下,再执行

./wsdl2h -o onvif.h -c -s -t ./typemap.dat remotediscovery.wsdl devicemgmt.wsdl

每个文件同样用空格分隔开。

注:typemap.dat 文件在下载的gsoap解压包内,自己去找。

wsdl2h的帮助信息见下:

**  The gSOAP WSDL/Schema processor for C and C++, wsdl2h release 2.8.23**  Copyright (C) 2000-2015 Robert van Engelen, Genivia Inc.**  All Rights Reserved. This product is provided "as is", without any warranty.**  The wsdl2h tool is released under one of the following licenses:**  GPL or the commercial license by Genivia Inc. Use option -l for details.Usage: wsdl2h [-a] [-b] [-c] [-d] [-e] [-f] [-g] [-h] [-I path] [-i] [-j] [-k] [-l] [-m] [-N name] [-n name] [-P|-p] [-q name] [-R] [-r proxyhost[:port[:uid:pwd]]] [-r:userid:passwd] [-s] [-t typemapfile] [-U] [-u] [-v] [-w] [-W] [-x] [-y] [-z#] [-_] [-o outfile.h] infile.wsdl infile.xsd http://www... ...-a      generate indexed struct names for local elements with anonymous types-b	bi-directional operations (duplex ops) added to serve one-way responses-c      generate C source code-d      use DOM to populate xs:any, xs:anyType, and xs:anyAttribute-e      don't qualify enum names-f      generate flat C++ class hierarchy-g      generate global top-level element declarations-h      display help info-Ipath  use path to find files-i      don't import (advanced option)-j      don't generate SOAP_ENV__Header and SOAP_ENV__Detail definitions-k      don't generate SOAP_ENV__Header mustUnderstand qualifiers-l      display license information-m      use xsd.h module to import primitive types-Nname  use name for service prefixes to produce a service for each binding-nname  use name as the base namespace prefix instead of 'ns'-ofile  output to file-P      don't create polymorphic types inherited from xsd__anyType-p      create polymorphic types inherited from base xsd__anyType-qname  use name for the C++ namespace of all declarations-R      generate REST operations for REST bindings in the WSDL-rhost[:port[:uid:pwd]]        connect via proxy host, port, and proxy credentials-r:uid:pwd        connect with authentication credentials (digest auth requires SSL)-s      don't generate STL code (no std::string and no std::vector)-tfile  use type map file instead of the default file typemap.dat-U      allow UTF8-encoded Unicode C/C++ identifiers when mapping XML tag names-u      don't generate unions-v      verbose output-W      suppress warnings-w      always wrap response parameters in a response struct (<=1.1.4 behavior)-x      don't generate _XML any/anyAttribute extensibility elements-y      generate typedef synonyms for structs and enums-z1     compatibility with 2.7.6e: generate pointer-based arrays-z2     compatibility with 2.7.7 to 2.7.15: qualify element/attribute references-z3     compatibility with 2.7.16 to 2.8.7: qualify element/attribute references-z4     compatibility up to 2.8.11: don't generate union structs in std::vector-z5     compatibility up to 2.8.15-z6     compatibility up to 2.8.17-_      don't generate _USCORE (replace with UNICODE _x005f)infile.wsdl infile.xsd http://www... list of input sources (if none: use stdin)

四、生成开发onvif用原文件

生成onvif.h头文件之后,即可根据soapcpp2命令生成C源文件或者CPP源文件。输入soapcpp2 -h,查看帮助

命令为:

./soapcpp2 -c   onvif.h -x -2 -I gsoap路径:gsoap/import路径 -d 生成后文件存放的路径

如果要生成cpp文件,则为:

./soapcpp2 -cpp onvif.h -x -2 -I gsoap路径:gsoap/import路径 -d 生成后文件存放的路径

注:其中-2参数是选择onvif 1.2 版本, 如果选择-1消息通知就无法被onvif测试工具识别

soapcpp2 的帮助信息见下:

[root@localhost bin]# ./soapcpp2 -hUsage: soapcpp2 [-0|-1|-2] [-C|-S] [-T] [-L] [-a] [-A] [-b] [-c] [-d path] [-e] [-f N] [-h] [-i] [-I path:path:...] [-k] [-l] [-m] [-n] [-p name] [-s] [-t] [-u] [-v] [-w] [-x] [-y] [-z#] [infile]-1      generate SOAP 1.1 bindings-2      generate SOAP 1.2 bindings-0      no SOAP bindings, use REST-C	generate client-side code only-S	generate server-side code only-T	generate server auto-test code-L	don't generate soapClientLib/soapServerLib-a	use SOAPAction with WS-Addressing to invoke server-side operations-A	require SOAPAction to invoke server-side operations-b	serialize byte arrays char[N] as string-c      generate C source code-dpath  use path to save files-e	generate SOAP RPC encoding style bindings (also use -1 or -2)-fN	file split of N XML serializer implementations per file (N>=10)-h	display help info-Ipath  use path(s) for #import (paths separated with ':')-i      generate C++ service proxies and objects inherited from soap struct-j      generate C++ service proxies and objects that share a soap struct-k      generate data structure walkers (experimental)-l      generate linkable modules (experimental)-m      generate Matlab(tm) code for MEX compiler-n      use service name to rename service functions and namespace table-pname  save files with new prefix name instead of 'soap'-Qname  use name as the C++ namespace for decls, including custom serializers-qname  use name as the C++ namespace for decls, excluding custom serializers-s      generate deserialization code with strict XML validation checks-t      generate code for fully xsi:type typed SOAP/XML messaging-u	uncomment comments in WSDL/schema output by suppressing XML comments-v	display version info-w	don't generate WSDL and schema files-x	don't generate sample XML message files-y	include C/C++ type access information in sample XML messages-z1	compatibility: generate old-style C++ service proxies and objects-z2	compatibility with 2.7.x: omit XML output for NULL pointersinfile	header file to parse (or stdin)

参考链接:http://blog.csdn.net/xuerongdeng/article/details/17927723

你可能感兴趣的文章
GEE学习笔记 六十八:【GEE之Python版教程二】配置Python开发环境
查看>>
GEE学习笔记 六十九:【GEE之Python版教程三】Python基础编程一
查看>>
GEE学习笔记 七十:【GEE之Python版教程四】Python基础编程二
查看>>
GEE学习笔记 七十一:【GEE之Python版教程五】Python基础编程三
查看>>
GEE学习笔记 七十二:【GEE之Python版教程六】命令行简介
查看>>
GEE学习笔记 七十三:【GEE之Python版教程七】静态展示影像和动态展示影像
查看>>
GEE学习笔记 七十五:【GEE之Python版教程九】数值
查看>>
GEE学习笔记 七十六:【GEE之Python版教程十】字典
查看>>
GEE学习笔记 七十七:GEE学习方法简介
查看>>
GEE学习笔记 七十八:干涸的洪泽湖
查看>>
GEE学习笔记 七十九:【GEE之Python版教程十一】列表
查看>>
一、windows安装Tomcat
查看>>
2012年02月21日的日记
查看>>
iSecret&nbsp;简介
查看>>
iSecret&nbsp;1.0&nbsp;正式上线啦!
查看>>
iSecret&nbsp;1.0&nbsp;销量尚可&nbsp;希望大家多…
查看>>
获取当前的内存占用&nbsp;(纯Linux底层…
查看>>
UIView的深入研究《转》
查看>>
29句最常用的英语谚语——管理…
查看>>
iSecret&nbsp;用户反馈专用
查看>>