onvif 客户端发现
1、解压:unzip -X gsoap_2.8.10.zip 编译
2、下载:
wget http://www.onvif.org/onvif/ver10/network/wsdl/remotediscovery.wsdl
3、复制:
cp gsoap-2.8/gsoap/typemap.dat .
4、在typemap.dat 中添加:
- #Use gSOAP 2.8.10 and up. In the typemap.dat file used by wsdl2h, add:
- # 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
- #Use gSOAP 2.8.10 and up. In the typemap.dat file used by wsdl2h, add:
- # 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
5、把编译好的wsdl2h,soapcpp2复制到本目录
6、./wsdl2h -o onvif.h -c -s -t typemap.dat remotediscovery.wsdl
7、./soapcpp2 -c onvif.h -x -I /workplace/mywork/onvif/gsoap-x86/gsoap-2.8/gsoap/import
8、复制文件:
cp gsoap-2.8/gsoap/stdsoap2.* .
9、测试代码:
- #include <iostream>
- #include "wsdd.nsmap"
- #include "soapH.h"
- using namespace std;
- int main()
- {
- struct soap *soap;
- struct wsdd__ProbeType req;
- struct __wsdd__ProbeMatches resp;
- struct wsdd__ScopesType sScope;
- struct SOAP_ENV__Header header;
- int count = 0;
- int result = 0;
- char guid_string[100];
- soap = soap_new();
- if(soap==NULL)
- {
- return -1;
- }
- soap_set_namespaces(soap, namespaces);
- soap->recv_timeout = 5; //超过5秒钟没有数据就退出
- soap_default_SOAP_ENV__Header(soap, &header);
- header.wsa__MessageID = guid_string;
- header.wsa__To= "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
- header.wsa__Action= "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe";
- soap->header = &header;
- soap_default_wsdd__ScopesType(soap, &sScope);
- sScope.__item = "";
- soap_default_wsdd__ProbeType(soap, &req);
- req.Scopes = &sScope;
- req.Types = "";
- result = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
- do{
- result = soap_recv___wsdd__ProbeMatches(soap, &resp);
- if (soap->error)
- {
- cout<<"soap error:"<<soap->error<<soap_faultcode(soap)<<"---"<<soap_faultstring(soap)<<endl;
- result = soap->error;
- break;
- }
- else
- {
- cout<<"========================================="<<endl;
- cout<<"Match size:"<<resp.wsdd__ProbeMatches->__sizeProbeMatch<<endl;
- cout<<"xsd-unsignedInt:"<<resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion<<endl;
- cout<<"scopes item:"<<resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item<<endl;
- //cout<<"scopes matchby:"<<resp.wsdd__ProbeMatches->ProbeMatch->Scopes->MatchBy<<endl;
- cout<<"QName:"<<resp.wsdd__ProbeMatches->ProbeMatch->Types<<endl;
- cout<<"xsd:string:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address<<endl;
- cout<<"xsd:QName:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.PortType<<endl;
- cout<<"wsa:ServiceNameType:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.ServiceName<<endl;
- cout<<"sequence of elements:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__size<<endl;
- cout<<"xsd:anyType:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__anyAttribute<<endl;
- cout<<"endpoint any:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__any<<endl;
- cout<<"wsdd:UriListType:"<<resp.wsdd__ProbeMatches->ProbeMatch->XAddrs<<endl;
- }
- }while(1);
- soap_destroy(soap); // remove deserialized class instances (C++ only)
- soap_end(soap); // clean up and remove deserialized data
- soap_done(soap);
- return result;
- }
- #include <iostream>
- #include "wsdd.nsmap"
- #include "soapH.h"
- using namespace std;
- int main()
- {
- struct soap *soap;
- struct wsdd__ProbeType req;
- struct __wsdd__ProbeMatches resp;
- struct wsdd__ScopesType sScope;
- struct SOAP_ENV__Header header;
- int count = 0;
- int result = 0;
- char guid_string[100];
- soap = soap_new();
- if(soap==NULL)
- {
- return -1;
- }
- soap_set_namespaces(soap, namespaces);
- soap->recv_timeout = 5; //超过5秒钟没有数据就退出
- soap_default_SOAP_ENV__Header(soap, &header);
- header.wsa__MessageID = guid_string;
- header.wsa__To= "urn:schemas-xmlsoap-org:ws:2005:04:discovery";
- header.wsa__Action= "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe";
- soap->header = &header;
- soap_default_wsdd__ScopesType(soap, &sScope);
- sScope.__item = "";
- soap_default_wsdd__ProbeType(soap, &req);
- req.Scopes = &sScope;
- req.Types = "";
- result = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
- do{
- result = soap_recv___wsdd__ProbeMatches(soap, &resp);
- if (soap->error)
- {
- cout<<"soap error:"<<soap->error<<soap_faultcode(soap)<<"---"<<soap_faultstring(soap)<<endl;
- result = soap->error;
- break;
- }
- else
- {
- cout<<"========================================="<<endl;
- cout<<"Match size:"<<resp.wsdd__ProbeMatches->__sizeProbeMatch<<endl;
- cout<<"xsd-unsignedInt:"<<resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion<<endl;
- cout<<"scopes item:"<<resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item<<endl;
- //cout<<"scopes matchby:"<<resp.wsdd__ProbeMatches->ProbeMatch->Scopes->MatchBy<<endl;
- cout<<"QName:"<<resp.wsdd__ProbeMatches->ProbeMatch->Types<<endl;
- cout<<"xsd:string:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address<<endl;
- cout<<"xsd:QName:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.PortType<<endl;
- cout<<"wsa:ServiceNameType:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.ServiceName<<endl;
- cout<<"sequence of elements:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__size<<endl;
- cout<<"xsd:anyType:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__anyAttribute<<endl;
- cout<<"endpoint any:"<<resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__any<<endl;
- cout<<"wsdd:UriListType:"<<resp.wsdd__ProbeMatches->ProbeMatch->XAddrs<<endl;
- }
- }while(1);
- soap_destroy(soap); // remove deserialized class instances (C++ only)
- soap_end(soap); // clean up and remove deserialized data
- soap_done(soap);
- return result;
- }
编译:g++ cc.cpp soapC.c stdsoap2.cpp soapClient.c -I/gsoap-2.8/gsoap
10、运行:./a.out
结果:
1、因为有多个ip(多个网卡)
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out
- soap error:-10x8a29778---0x8a2977c
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out
- soap error:-10x8a29778---0x8a2977c
2、只有一个网卡,且ip所在网段正好有两个支持onvif的设备:
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out
- =========================================
- Match size:1
- xsd-unsignedInt:1
- scopes item:onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/type/ptz onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/type/network_video_transmitter onvif://www.onvif.org/hardware/DM368 onvif://www.onvif.org/location/country/china onvif://www.onvif.org/name/Dahua
- QName:tdn:NetworkVideoTransmitter
- xsd:string:urn:uuid:5b71c61f-220b-475d-9eca-dd7941f07767
- xsd:QName:0
- wsa:ServiceNameType:0
- sequence of elements:0
- xsd:anyType:
- endpoint any:0
- wsdd:UriListType:http://192.168.9.110:9988/onvif/device_service
- soap error:-10x87a99f8---0x87a99fc
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out
- =========================================
- Match size:1
- xsd-unsignedInt:1
- scopes item:onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/type/ptz onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/type/network_video_transmitter onvif://www.onvif.org/hardware/DM368 onvif://www.onvif.org/location/country/china onvif://www.onvif.org/name/Dahua
- QName:tdn:NetworkVideoTransmitter
- xsd:string:urn:uuid:5b71c61f-220b-475d-9eca-dd7941f07767
- xsd:QName:0
- wsa:ServiceNameType:0
- sequence of elements:0
- xsd:anyType:
- endpoint any:0
- wsdd:UriListType:http://192.168.9.110:9988/onvif/device_service
- soap error:-10x86929f8---0x86929fc
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out
- =========================================
- Match size:1
- xsd-unsignedInt:1
- scopes item:onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/type/ptz onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/type/network_video_transmitter onvif://www.onvif.org/hardware/DM368 onvif://www.onvif.org/location/country/china onvif://www.onvif.org/name/Dahua
- QName:tdn:NetworkVideoTransmitter
- xsd:string:urn:uuid:5b71c61f-220b-475d-9eca-dd7941f07767
- xsd:QName:0
- wsa:ServiceNameType:0
- sequence of elements:0
- xsd:anyType:
- endpoint any:0
- wsdd:UriListType:http://192.168.9.110:9988/onvif/device_service
- soap error:-10x87a99f8---0x87a99fc
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$
- xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out
- =========================================
- Match size:1
- xsd-unsignedInt:1
- scopes item:onvif://www.onvif.org/type/video_encoder onvif://www.onvif.org/type/ptz onvif://www.onvif.org/type/audio_encoder onvif://www.onvif.org/type/network_video_transmitter onvif://www.onvif.org/hardware/DM368 onvif://www.onvif.org/location/country/china onvif://www.onvif.org/name/Dahua
- QName:tdn:NetworkVideoTransmitter
- xsd:string:urn:uuid:5b71c61f-220b-475d-9eca-dd7941f07767
- xsd:QName:0
- wsa:ServiceNameType:0
- sequence of elements:0
- xsd:anyType:
- endpoint any:0
- wsdd:UriListType:http://192.168.9.110:9988/onvif/device_service
- soap error:-10x86929f8---0x86929fc
参考:
http://my.oschina.net/yunuo/blog/119206
http://blog.csdn.net/ghostyu/article/details/8182516
onvif 客户端发现相关推荐
- onvif学习笔记8:最近写的一个ONVIF客户端的心得小结
最近,利用业余时间编写一个简单的ONVIF客户端MFC程序,这里记录一下过程. 语言选择 在之前调查过,有用QT实现的,有用python实现的,虽然正在学python,无奈才看了3天的书,没自信去搞. ...
- ONVIF客户端搜索设备获取rtsp地址开发笔记(精华篇)
概要: 目前ONVIF协议家族设备已占据数字监控行业半壁江山以上,亲,作为开发者的你还在犹豫是否了解下吗?本文介绍了ONVIF客户端从设备搜索,鉴权,能力获取,媒体信息获取,URI地址获取的整套流 ...
- 【视频开发】ONVIF客户端搜索设备获取rtsp地址开发笔记(精华篇)
转载地址:http://blog.csdn.net/gubenpeiyuan/article/details/25618177 概要: 目前ONVIF协议家族设备已占据数字监控行业 ...
- onvif客户端(转载)
本文为转载文章,文章出处为:https://www.cnblogs.com/rongpmcu/p/10351204.html 如果有侵权请及时联系删除,如想转载请先去联系原作者 onvif客户端 前言 ...
- 关于 客户端发现响应内容类型为“text/html; charset=utf-8”,但应为“text/xml”的解决方法...
关于 客户端发现响应内容类型为"text/html; charset=utf-8",但应为"text/xml"的解决方法 请求web服务时,会有如题的异常出现, ...
- SCCM 2012 R2---配置客户端发现方法和边界组
二.安装SCCM 2012 R2客户端 1.配置SCCM 2012 R2客户端发现方法 安装完成后我们打开SCCM 2012 R2的控制台: 点击左侧栏的"管理"选项,然后展开&q ...
- SCCM2012之客户端发现与安装
通过前面两次实验,我们已经完成了SCCM 2012的安装,下面就开始进入SCCM 2012的管理与使用.进入管理控制台,我们可以发现SCCM 2012管理控制台与前作发生了很大的变化,整个界面添加了如 ...
- SCCM2012SP1---配置客户端发现方法和边界组
二.安装SCCM客户端 1.配置SCCM 2012客户端发现方法 安装完成后我们打开SCCM 2012的控制台: 点击左侧栏的"管理"选项,然后展开"层次结构配置&quo ...
- SCCM2012R2部署之四:配置客户端发现
前面3个章节我们简单的,介绍了安装配置和相关的组件.接下来我们需要给大家介绍的是如何配置客户端发现,让SCCM能真正管控到AD中的所有终端,来提供IT运维的效率. 首先我们打开SCCM控制台,如图4- ...
最新文章
- 本人在学习PHP过程中的随笔心得
- GIT:本地有更改,但强制作远程仓库里作更新
- 444牛X的日常口语
- 可遇不可求的BUG之采用MYSQL odbc 3.51访问数据库返回值缺失
- python简单代码input-python基础 input()函数
- 详细学习ORACLE JOBS
- EF6 CodeFirst+Repository+Ninject+MVC4+EasyUI实践(六)
- 线程间操作无效: 从不是创建控件“progressBar1”的线程访问它。
- 若5G的速度不够:那6G和16K是必然么?
- CentOS安装scp命令
- 公共技术点之 Java 注解 Annotation
- c#获取本地ip地址网关子网掩码_C#--WinForm获取本机网卡的型号,IP地址,子网掩码和网关-阿里云开发者社区...
- spark-08-SparkStraming简介与kafka0.8集群安装
- LeetCode 84. Largest Rectangle in Histogram
- android手机上传不了图片,【报Bug】nvue页面使用web-view组件,安卓手机无法调用页面的input标签上传图片...
- Delphi之TClientSocket和TServerSocket使用tcp keepalive心跳机制实现“断网”、断电检测...
- 需要什么数据?要说清楚、准确
- 制作一个模拟Windows启动界面的文本进度条python
- 梯度消失和爆炸原因以及解决方法
- python实现电子邮件编程