2. gsoap官网:http://www.cs.fsu.edu/~engelen/soap.html
二、操作步骤
1. 下载gsoap
在gsoap官网旁边,有sourceforge的链接,去那里下源码。https://sourceforge.net/projects/gsoap2/files/?source=navbar
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.在线方式:
每个链接用空格分隔开。
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 -h Usage: 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 pointers infile header file to parse (or stdin)
参考链接:http://blog.csdn.net/xuerongdeng/article/details/17927723