GSOAP编译,并生成ONVIF框架

编程入门 行业动态 更新时间:2024-10-28 07:24:09

GSOAP编译,并生成ONVIF<a href=https://www.elefans.com/category/jswz/34/1770644.html style=框架"/>

GSOAP编译,并生成ONVIF框架

最近又重新生成了一遍onvif的框架,相对于以前有了一些改变,例如onvif文档变成了https。
接下来将详细的生成过程进行描述:

本次生成过程是基于Redhat8.2的系统环境

  1. 下载GSOAP开源版
    下载gsoap

  2. GSOAP官方文档
    官方网页

  3. 编译前需要先编译安装bison、flex、openssl
    a. 下载flex2.6.4
    b. 下载bison3.8
    c. 下载openssl1.1.q openssl 可以用已经装好的版本

  4. 编译前还需安装部分东西

    yum install libtool
    yum install gettext gettext-devel gettext-common-devel
    yum -y install gcc automake autoconf libtool make
    yum -y install m4
    yum -y install bison flex
    
  5. 编译bison

    xz -d bison-3.8.tar.xz
    tar -xvf bison-3.8.tar
    cd bison-3.8/
    ./configure
    make -j 6
    make install
    
  6. 编译flex

    wget .6.4.tar.gz
    tar -zxvf flex-2.6.4.tar.gz
    cd flex-2.6.4/
    mkdir build
    cd build
    ../configure
    make -j 6
    make install
    
  7. 编译gsoap

    wget .8.122.zip
    unzip gsoap_2.8.122.zip
    cd gsoap-2.8/
    ./configure --help
    ./configure
    make -j 6
    make install
    ln -sf /usr/local/bin/wsdl2h /usr/bin/wsdl2h
    ln -sf /usr/local/bin/soapcpp2 /usr/bin/soapcpp2
    cd gsoap
    mkdir onvif
    vim typemap.dat
    #去掉xsd__duration = #import "custom/duration.h" | xsd__duration 前面的注释
    #修改命名空间如下
    tds     = ""
    tev     = ""
    tls     = ""
    tmd     = ""
    timg    = ""
    trt     = ""
    tr2     = ""
    tptz    = ""
    trv     = ""
    trc     = ""
    tse     = ""
    trp     = ""
    tan     = ""
    tad     = ""
    tas     = ""
    tdn     = ""
    tt      = ""tac     = ""
    tar     = ""
    tae     = ""
    tas     = ""
    tab     = ""
    tcr     = ""
    tdc     = ""
    tpv     = ""
    tsc     = ""
    tth     = ""
    tup     = ""
    pt      = ""
    thf     = ""
    thb     = ""
    tns     = ""#输入指令
    wsdl2h -t ./typemap.dat -o onvif/onvif.h .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl .wsdl  .wsdl .wsdl .wsdlvim onvif/onvif.h
    # 添加 #import "wsse.h"
    soapcpp2 -2 -x -L -I import:custom -d onvif/ onvif/onvif.h
    cp stdsoap2.c stdsoap2.h dom.c plugin/wsaapi.c plugin/wsaapi.h custom/duration.c custom/duration.h plugin/threads.c plugin\threads.h plugin\smdevp.c plugin\smdevp.h plugin\mecevp.c plugin\mecevp.h plugin\wsseapi.h plugin\wsseapi.c plugin\wsddapi.h plugin\wsddapi.c onvif/
    # 将duration.c 修改为duration.cpp(duration.c 可能编译不过)
    # 完成编译
    
  8. 编写实例

    #编译实例
    #编译过程中有些警告或者类型转换错误,直接正常修改即可。
    #若出现无法链接的符合,加上-DWITH_OPENSSL试试
    #编译客户端或服务端的时候注意soapClient.cpp和soapServer.cpp只有一个
    #无法解析的外部符号namespaces,添加头文件#include “onvif.nsmap”
    #里面有多个nsmap,随便找一个重命名为onvif.nsmap
    #最后需要再 onvif\stdsoap2.c文件,在开头加入:#include “onvif.nsmap”

使用举例:

int main()
{    struct soap* soap = soap_new();soap->send_timeout = 5;soap->recv_timeout = 5;soap->connect_timeout = 5;do {soap->user = (char*)_strUserName.c_str();soap->passwd = (char*)_strPassword.c_str();_tds__GetDeviceInformation req;_tds__GetDeviceInformationResponse rsp;soap_wsse_add_UsernameTokenDigest(soap, NULL, _strUserName.c_str(), _strPassword.c_str());auto ret = soap_call___tds__GetDeviceInformation(soap,strDevAddr.c_str(), NULL, &req, rsp);if (ret != SOAP_OK){LOG_ERROR(*context_onvif->pLogger, "<%s>: soap_call___tds__GetDeviceInformation failed. soap code: %?d, ip: %s id: %s",string(__FUNCTION__), ret, _strDeviceIp, _strDeviceId);break;}LOG_INFO(*context_onvif->pLogger, "<%s>: device Info: %s-%s-%s-%s-%s. ip: %s id: %s",string(__FUNCTION__), rsp.FirmwareVersion, rsp.HardwareId, rsp.HardwareId, rsp.Manufacturer, rsp.Model, _strDeviceIp, _strDeviceId);} while (false);soap_destroy(soap); // delete managed objectssoap_end(soap);     // delete managed data and temporaries soap_free(soap);    // finalize and delete the context
}

更多推荐

GSOAP编译,并生成ONVIF框架

本文发布于:2023-12-06 04:12:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1666400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:框架   GSOAP   ONVIF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!