博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
onvif 设备自发现测试通过
阅读量:3558 次
发布时间:2019-05-20

本文共 5987 字,大约阅读时间需要 19 分钟。

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 prefixestds	= "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 prefixeswsnt	= "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 remappingwsdd10__HelloType		= | wsdd__HelloTypewsdd10__ByeType			= | wsdd__ByeTypewsdd10__ProbeType		= | wsdd__ProbeTypewsdd10__ProbeMatchesType	= | wsdd__ProbeMatchesTypewsdd10__ProbeMatchType		= | wsdd__ProbeMatchTypewsdd10__ResolveType		= | wsdd__ResolveTypewsdd10__ResolveMatchesType	= | wsdd__ResolveMatchesTypewsdd10__ResolveMatchType	= | wsdd__ResolveMatchType#	SOAP-ENV mappingSOAP_ENV__Envelope	= struct SOAP_ENV__Envelope { struct SOAP_ENV__Header *SOAP_ENV__Header; _XML SOAP_ENV__Body; }; | struct SOAP_ENV__EnvelopeSOAP_ENV__Header	= | struct SOAP_ENV__HeaderSOAP_ENV__Fault		= | struct SOAP_ENV__FaultSOAP_ENV__Detail	= | struct SOAP_ENV__DetailSOAP_ENV__Code		= | struct SOAP_ENV__CodeSOAP_ENV__Subcode	= | struct SOAP_ENV__SubcodeSOAP_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 
#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:"<
error<
<<"---"<
<
error; break; } else { cout<<"========================================="<
__sizeProbeMatch<
ProbeMatch->MetadataVersion<
ProbeMatch->Scopes->__item<
ProbeMatch->Scopes->MatchBy<
ProbeMatch->Types<
ProbeMatch->wsa__EndpointReference.Address<
ProbeMatch->wsa__EndpointReference.PortType<
ProbeMatch->wsa__EndpointReference.ServiceName<
ProbeMatch->wsa__EndpointReference.__size<
ProbeMatch->wsa__EndpointReference.__anyAttribute<
ProbeMatch->wsa__EndpointReference.__any<
ProbeMatch->XAddrs<

编译: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

2、只有一个网卡,且ip所在网段正好有两个支持onvif的设备:

xy@xy-pc:/workplace/mywork/onvif/gsoap-x86/mytest/myonvif/test$ ./a.out =========================================Match size:1xsd-unsignedInt:1scopes 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/DahuaQName:tdn:NetworkVideoTransmitterxsd:string:urn:uuid:5b71c61f-220b-475d-9eca-dd7941f07767xsd:QName:0wsa:ServiceNameType:0sequence of elements:0xsd:anyType:endpoint any:0wsdd:UriListType:http://192.168.9.110:9988/onvif/device_servicesoap error:-10x87a99f8---0x87a99fcxy@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:1xsd-unsignedInt:1scopes 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/DahuaQName:tdn:NetworkVideoTransmitterxsd:string:urn:uuid:5b71c61f-220b-475d-9eca-dd7941f07767xsd:QName:0wsa:ServiceNameType:0sequence of elements:0xsd:anyType:endpoint any:0wsdd:UriListType:http://192.168.9.110:9988/onvif/device_servicesoap error:-10x86929f8---0x86929fc

参考:

http://my.oschina.net/yunuo/blog/119206

/link.php?url=http://blog.csdn.net/ghostyu/article/details/8182516

作者:xyyangkun 发表于2013-6-18 17:37:39 
你可能感兴趣的文章
梯度下降:BGD、SGD、mini-batch GD介绍及其优缺点
查看>>
【论文笔记】:Learning from Noisy Anchors for One-stage Object Detection
查看>>
Ubuntu18.04下opencv3.4.3编译与安装,及常见问题记录
查看>>
【论文笔记】:PSS(NMS-free)
查看>>
2022届春招实习面经(CV岗)——凉经
查看>>
2022届春招实习面经(CV岗)——offer经
查看>>
【论文笔记】:PP-YOLO、PP-YOLOv2、PP-YOLO Tiny
查看>>
【论文笔记】:Swin transformer(转载)
查看>>
(转载)注意力机制中的Q、K和V的意义
查看>>
安装Anaconda3遇到的几个问题
查看>>
Linux设置anaconda3的环境变量
查看>>
COCO数据集标注格式详解----object instances
查看>>
【论文整理】:R-CNN、fast R-CNN、faster R-CNN三者的整理
查看>>
【干货】用mmdetection,在COCO数据集上跑通faster R-CNN(测试、训练)
查看>>
numpy数组切片操作之[:,2]、[-1:,0:2]、[1:,-1:]等都是啥?
查看>>
CrowdHuman数据集格式 ——odgt文件格式
查看>>
【干货】CrowdHuman数据集标注格式odgt转COCO数据集标注格式json(附详细代码)
查看>>
【干货】mmdetection使用coco格式的CrowdHuman数据集进行训练及测试(附调参过程)
查看>>
【论文笔记】:FPN
查看>>
【论文笔记】:Focal Loss for Dense Object Detection
查看>>