前期准备的文件
onvif官网 下载ptz.wsdl 文件
在ptz.wsdl上右键选择 “链接另存为”
使用WSDL2h 将 ptz.wsdl转为 .h文件
(1)WSDL2h.exe 在gsoap-2.8\gsoap\bin\win64 目录下,将gsoap-2.8\gsoap\typemap.dat 也复制到exe目录下
调用命令示例:
ssl_wsdl2h.exe -o ptz.h https://www.onvif.org/ver20/ptz/wsdl/ptz.wsdl
I.typemap.dat 按文件名理解,应该是各种数据对于的数据类型的map,生成.h时需要,否则会找不到的错误,
II. 因为需要用到time_duration,需要先修改 typemap.dat 文件218行,将注释取消
# Uncomment the line below to use LONG64 int for xsd:duration instead of
# mapping xsd:duration to string (in milliseconds precision).
# Then rerun wsdl2h and also compile and link custom/duration.c.
#
xsd__duration = #import "custom/duration.h" | xsd__duration
III.使用不带 SSL 的 WSDL2h 会报错
Cannot connect to https site: SSL/TLS support not enabled in this version. Visit https://www.genivia.com/downloads.html to download the secure version of wsdl2h.exe that supports SSL/TLS to connect to https sites.
解决办法:可以使用源码编译一个带SSL的WSDL2h,步骤可以参考在windows下编译支持SSL/TLS的wsdl2h
将生成好的头文件调用soapcpp2.exe生成最终需要的class
#通过共享SOAP结构,生成C++服务代理和对象, -p 命令替换soap默认的前缀
soapcpp2 -j -p ptz ptz.h
#或者分别生成 server client
soapcpp2 -S -p ptz ptz.h
soapcpp2 -C -p ptz ptz.h
最终我们会拿到需要的
#proxy
ptzPTZBindingProxy.h
ptzPTZBindingService.h
ptzStub.h
ptzH.h
PTZBinding.nsmap
#或者 client server相关的文件
ptzServer.cpp
ptzClient.cpp
带SSL的WSDL2h已经最终生成的文件下载地址gsoap2.8+生成头文件