分享

onvif学习之onvif代码框架

 gljin_cn 2014-08-05

一,通过wsdl2h获取onvif.h文件

在使用wsdl2h产生头文件前需要修改typemap.dat,

修改的依据在这里:http://www.cs./~engelen/soap.html,在FAQ页面下的How do I use gSOAP for the ONVIF specifications?

root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# cat typemap.dat
#Use gSOAP 2.8.10 and up. In the typemap.dat file used by wsdl2h, add:
ONVIF recommended prefixes
tds = "http://www./ver10/device/wsdl"
tev = "http://www./ver10/events/wsdl"
tls = "http://www./ver10/display/wsdl"
tmd = "http://www./ver10/deviceIO/wsdl"
timg = "http://www./ver20/imaging/wsdl"
trt = "http://www./ver10/media/wsdl"
tptz = "http://www./ver20/ptz/wsdl"
trv = "http://www./ver10/receiver/wsdl"
trc = "http://www./ver10/recording/wsdl"
tse = "http://www./ver10/search/wsdl"
trp = "http://www./ver10/replay/wsdl"
tan = "http://www./ver20/analytics/wsdl"
tad = "http://www./ver10/analyticsdevice/wsdl"
tdn = "http://www./ver10/network/wsdl"
tt = "http://www./ver10/schema"
OASIS recommended prefixes
wsnt = "http://docs./wsn/b-2"
wsntw = "http://docs./wsn/bw-2"
wsrfbf = "http://docs./wsrf/bf-2"
wsrfr = "http://docs./wsrf/r-2"
wsrfrw  = "http://docs./wsrf/rw-2"
wstop = "http://docs./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
root@microcreat:/workdir/private/onvif/workdir/onvif_discovery#

  根据onvif官网提供的remotediscovery.wsdl产生onvif.h头文件

关于onvif所有的wsdl都在这里:http://www./Documents/Specifications.aspx中的ONVIF WSDL and XML Schemas Specifications一节,虽然可以全部下载为wsdl文件,但是wsdl文件中存在相互依赖的关系,并且是带有存储的依赖,所以最好直接使用url来产生头文件,不要下载下来。

root@microcreat:/workdir/private/onvif/workdir# mkdir onvif_discovery
root@microcreat:/workdir/private/onvif/workdir# cd onvif_discovery/
root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# ls
root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# pwd
/workdir/private/onvif/workdir/onvif_discovery
root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# ls
root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# wsdl2h -o onvif.h -c -s -t ./typemap.dat http://www./onvif/ver10/network/wsdl/remotediscovery.wsdl

**  The gSOAP WSDL/Schema processor for C and C++, wsdl2h release 2.8.12
**  Copyright (C) 2000-2012 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 two licenses:
**  GPL or the commercial license by Genivia Inc. Use option -l for details.

Saving onvif.h

Reading type definitions from type map file './typemap.dat'

Connecting to 'http://www./onvif/ver10/network/wsdl/remotediscovery.wsdl' to retrieve WSDL/XSD...
Connected, receiving...

Connecting to 'http://schemas./ws/2005/04/discovery/ws-discovery.xsd' to retrieve schema...
Connected, receiving...
Done reading 'http://schemas./ws/2005/04/discovery/ws-discovery.xsd'

Connecting to 'http://schemas./ws/2004/08/addressing' to retrieve schema...
Connected, receiving...
Redirected to 'http://schemas./ws/2004/08/addressing/'...

Connecting to 'http://schemas./ws/2004/08/addressing/' to retrieve schema...
Connected, receiving...
Done reading ''
Done reading 'http://www./onvif/ver10/network/wsdl/remotediscovery.wsdl'

To complete the process, compile with:
> soapcpp2 onvif.h

root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# ls
onvif.h  typemap.dat

root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# soapcpp2 -c onvif.h -x -I /workdir/private/onvif/gsoap-2.8/gsoap/import -I /workdir/private/onvif/gsoap-2.8/gsoap/ 

**  The gSOAP code generator for C and C++, soapcpp2 release 2.8.12
**  Copyright (C) 2000-2012, Robert van Engelen, Genivia Inc.
**  All Rights Reserved. This product is provided "as is", without any warranty.
**  The soapcpp2 tool is released under one of the following two licenses:
**  GPL or the commercial license by Genivia Inc.

Saving soapStub.h annotated copy of the input declarations
Using tdn service name: RemoteDiscoveryBinding
Using tdn service style: document
Using tdn service encoding: literal
Using tdn service location: http://localhost:80
Using tdn schema namespace: http://www./ver10/network/wsdl
Saving RemoteDiscoveryBinding.nsmap namespace mapping table
Saving soapClient.c client calling stubs
Saving soapClientLib.c client stubs with serializers (use only for libs)
Saving soapServer.c server request dispatcher
Saving soapServerLib.c server request dispatcher with serializers (use only for libs)
Saving soapH.h interface declarations
Saving soapC.c XML serializers

Compilation successful 

root@microcreat:/workdir/private/onvif/workdir/onvif_discovery# ls
onvif.h                       soapC.c       soapClientLib.c  soapServer.c     soapStub.h
RemoteDiscoveryBinding.nsmap  soapClient.c  soapH.h          soapServerLib.c  typemap.dat
  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多