gsoap+onvif编译-成都快上网建站

gsoap+onvif编译

/*********************************************gsoap onvif 客户端功能开发****************************************************************************************/

1.编译ssl ,其中安装目录会被gsoap编译时用到
见17行

2.gsoap
unzip gsoap_2.8.34.zip
./configure --with-openssl=/home/llf/x86/openssl-install  (此为openssl安装目录) 如果为arm,还需要--host=
make
sudo make install

3. gsoap/import/wsa5.h 注销277行 int SOAP_ENV__Fault 定义

4.修改gsoap/typemap.dat
Use gSOAP 2.8.10 or greater. In the typemap.dat file that is used by wsdl2h, add the following if not already there:

#   ONVIF recommended prefixes
tds = "http://www.onvif.org/ver10/device/wsdl"
tev = "http://www.onvif.org/ver10/events/wsdl"
tls = "http://www.onvif.org/ver10/display/wsdl"
tmd = "http://www.onvif.org/ver10/deviceIO/wsdl"
timg        = "http://www.onvif.org/ver20/imaging/wsdl"
trt = "http://www.onvif.org/ver10/media/wsdl"
tptz        = "http://www.onvif.org/ver20/ptz/wsdl"
trv = "http://www.onvif.org/ver10/receiver/wsdl"
trc = "http://www.onvif.org/ver10/recording/wsdl"
tse = "http://www.onvif.org/ver10/search/wsdl"
trp = "http://www.onvif.org/ver10/replay/wsdl"
tan = "http://www.onvif.org/ver20/analytics/wsdl"
tad = "http://www.onvif.org/ver10/analyticsdevice/wsdl"
tdn = "http://www.onvif.org/ver10/network/wsdl"
tt  = "http://www.onvif.org/ver10/schema"
#   OASIS recommended prefixes
wsnt        = "http://docs.oasis-open.org/wsn/b-2"
wsntw       = "http://docs.oasis-open.org/wsn/bw-2"
wsrfbf      = "http://docs.oasis-open.org/wsrf/bf-2"
wsrfr       = "http://docs.oasis-open.org/wsrf/r-2"
wsrfrw  = "http://docs.oasis-open.org/wsrf/rw-2"
wstop       = "http://docs.oasis-open.org/wsn/t-1"
#   WS-Discovery 1.0 remapping
wsdd10__HelloType           = | wsdd__HelloType
wsdd10__ByeType                     = | wsdd__ByeType
wsdd10__ProbeType           = | wsdd__ProbeType
wsdd10__ProbeMatchesType    = | wsdd__ProbeMatchesType
wsdd10__ProbeMatchType              = | wsdd__ProbeMatchType
wsdd10__ResolveType         = | wsdd__ResolveType
wsdd10__ResolveMatchesType  = | wsdd__ResolveMatchesType
wsdd10__ResolveMatchType    = | wsdd__ResolveMatchType
#   SOAP-ENV mapping
SOAP_ENV__Envelope  = struct SOAP_ENV__Envelope { struct SOAP_ENV__Header *SOAP_ENV__Header; _XML SOAP_ENV__Body; }; | struct SOAP_ENV__Envelope
SOAP_ENV__Header    = | struct SOAP_ENV__Header
SOAP_ENV__Fault             = | struct SOAP_ENV__Fault
SOAP_ENV__Detail    = | struct SOAP_ENV__Detail
SOAP_ENV__Code              = | struct SOAP_ENV__Code
SOAP_ENV__Subcode   = | struct SOAP_ENV__Subcode
SOAP_ENV__Reason    = | struct SOAP_ENV__Reason

4.onvif.h 生成
copy typedamp.dat 到命令所在目录
wsdl2h -P -x  -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/display.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/ver20/ptz/wsdl/ptz.wsdl http://www.onvif.org/onvif/ver10/receiver.wsdl http://www.onvif.org/onvif/ver10/recording.wsdl http://www.onvif.org/onvif/ver10/search.wsdl http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl http://www.onvif.org/onvif/ver10/replay.wsdl
注意:Note that the specifications are substantial in size. Option wsdl2h -P removes unnecessary class hierarchy dependences on the root type xsd__anyType. This option will reduce the code size. Option wsdl2h -x removes extensibility elements (xsd:anyAttribute attributes and xsd:any elements). If attribute and element extensions to a complexType are needed, then use the typemap.dat file to add these as additional optional members. For example, to extend tt__AudioDecoderConfigurationOptionsExtension complexType class with an element Address of type tt:IPAddress, then add to typemap.dat:
tt__AudioDecoderConfigurationOptionsExtension = $ tt__IPAddress Address;

5.onvif.h 中添加 #import "wsse.h"

6.生成gsoap骨架代码
soapcpp2  -2 -L -x -i -Ed -f100 -d ../../onvifgen -I../../gsoap/import:../../gsoap  onvif.h
注:-f100 会生成多个soap文件,每个文件有N个序列化程序定义.如果不加此选项,生成的soapC.cpp文件有16M之大,编译会卡死
注:Option soapcpp2 -2 forces SOAP 1.2, which is required by ONVIF. In some cases the wsdl2h conversion may not detect SOAP 1.2 and therefore we recommend this option.
Compile the soapcpp2-generated code together with custom/duration.c.
If WS-Discovery is used (e.g. with ONVIF remotediscovery), also include plugin/wsddapi.h in your code and compile plugin/wsddapi.c (see WS-Discovery documentation.
If it appears that multiple service operations are generated with the same name, such as GetServices and GetServices_ then remove http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl from the command line list of URLs because this WSDL is already imported by another WSDL.

7. 注销生成的soapStub.h中 #define SOAP_WSA_2005

8.编译自己的程序
需加入ssl头文件位置  -I/home/llf/x86/openssl-install/include 及库文件位置 -L/home/llf/x86/openssl-install/lib/

9.g++ 编译时 -lgsoapssl++ -lssl -lcrypto -lz -lpthread 必须放到最后,且必须这个顺序,不能放到-o的前面。否则链接不过,会报undedined reference...。

10年积累的网站设计、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有玉泉街道免费网站建设让你可以放心的选择与我们合作。


标题名称:gsoap+onvif编译
文章地址:http://kswjz.com/article/pcdpco.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流