Windows下用gSoap编译Onvif框架流程总结

Windows下用gSoap编译Onvif框架流程总结

 

1、wsdl2h.exe使用

1)    在Onvif官网Specification页面中下载提供的功能相应的wsdl文件,如analytics.wsdldevicemgmt.wsdl等。地址

   http://www.onvif.org/Documents/Specifications.aspx

 

2 )运行wsdl2h.exe程序需要访问网络。若你的电脑无法访问编译头文件所需要的网站,或者希望节省访问网页所造成的长时间等待,可预先打开相应的网站,保存为本地文件。如onvif.xsd和其标明要用的b-2.xsd, t-1.xsd,bf-2.xsd等文件。地址在

  http://www.onvif.org/onvif/ver10/schema/onvif.xsd 

 http://docs.oasis-open.org/wsn/b-2.xsd

 http://docs.oasis-open.org/wsrf/bf-2.xsd

   然后打开头文件,将<schemaLocation> 内的出现b-2.xsd的网址改成本地路径。如schemaLocation=”http://docs.oasis-open.org/wsn/b-2.xsd”改成schemaLocation=”d:\onvif\ver10\schema\b-2.xsd”

   下面wsdl2h.exe 运行时需要什么网页就下载什么网页就行。需要的网页大约有6,7个,需要点耐心下载。

 

3)    运行 wsdl2h.exe -sck -o Soapstub.h analytics.wsdl analyticsdevice.wsdl devicemgmt.wsdl display.wsdl event.wsdl imaging.wsdl media.wsdl ptz.wsdl receiver.wsdl recording.wsdl remotediscovery.wsdl replay.wsdl search.wsdl deviceio.wsdl

生成Onvif的头文件 Soapstub.h

其中参数:
    -s      don't generate STL code (no std::string and no std::vector)
    -c      generate C source code
    -k      don't generate SOAP_ENV__Header mustUnderstand qualifiers
    -tfile  use type map file instead of the default file typemap.dat
    -ofile  output to file

 

2soapcpp2.exe使用

1)运行D:\gsoap-2.8.15\gsoap\bin\win32>soapcpp2.exe -2 -L -c -x -I../../;../../import;../../custom  d:/ Soapstub.h

“-I”后面代表要include的文件夹。由于不能使用冒号,所以不能从“d:”开始写,只能写相对路径了。或许是我不懂,请指教。另外,目录层次间用“/”,而不是“\”。需要include的文件有gsoap;gsoap/import;gsoap/import;gsoap/custom

2)编译成功会生成soapC.c, soapClient.c, soapServer.c, soapH.h, soapStub.h

 

注:

1)提示ns1.h找不到错误是由于typemaptypemap.dat用错导致的。当你不知道他们是什么的时候,请不要使用-t typemap参数。省略就好。

2)不同版本gsoap产生的nsmap的结构体名字不一样,请注意。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
使用gSOAP生成ONVIF框架代码需要遵循以下步骤: 1. 下载gSOAP工具包并安装到本地。 2. 下载ONVIF设备WSDL文件,例如https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl。 3. 使用gSOAP工具包中的wsdl2h工具将WSDL文件转换为头文件。 4. 使用soapcpp2工具生成ONVIF框架代码,例如: ```bash soapcpp2 -Iimport devicemgmt.h ``` 5. 在生成的代码中实现ONVIF设备的具体操作。 以下是在Linux系统中使用gSOAP生成ONVIF框架代码的示例: 1. 下载gSOAP工具包并安装到本地: ```bash wget https://sourceforge.net/projects/gsoap2/files/gSOAP/gsoap_2.8.112.zip unzip gsoap_2.8.112.zip cd gsoap-2.8 ./configure make sudo make install ``` 2. 下载ONVIF设备WSDL文件: ```bash wget https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl ``` 3. 使用wsdl2h工具将WSDL文件转换为头文件: ```bash wsdl2h -o onvif.h devicemgmt.wsdl ``` 4. 使用soapcpp2工具生成ONVIF框架代码: ```bash soapcpp2 -Iimport onvif.h ``` 5. 在生成的代码中实现ONVIF设备的具体操作。 在生成的代码中,每个ONVIF操作都有对应的函数,例如`SOAP_FMAC5 int SOAP_FMAC6 __tds__GetDeviceInformation(struct soap* soap, _tds__GetDeviceInformation* tds__GetDeviceInformation, _tds__GetDeviceInformationResponse &tds__GetDeviceInformationResponse)`就是获取设备信息的函数。您可以在这些函数中实现具体的操作。 另外,生成的代码中还有一些辅助函数和结构体,您也可以根据需要使用它们。 例如,以下代码片段演示了如何创建一个SOAP客户端并调用`__tds__GetDeviceInformation`函数: ```c++ #include "soapDeviceBindingProxy.h" const char* endpoint = "http://192.168.1.100/onvif/device_service"; DeviceBindingProxy proxy; proxy.soap_endpoint = endpoint; _tds__GetDeviceInformation tds__GetDeviceInformation; _tds__GetDeviceInformationResponse tds__GetDeviceInformationResponse; proxy.__tds__GetDeviceInformation(&tds__GetDeviceInformation, tds__GetDeviceInformationResponse); // 处理返回值 ``` 在使用时,需要将`endpoint`替换为实际的设备IP地址和ONVIF服务端口号。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值