代码拉取完成,页面将自动刷新
#include "stdafx.h"
#include "Onvif.h"
#include "Soap\soapH.h"
#include "Soap\stdsoap2.h"
#include "Soap\soapStub.h"
#include "wsddapi.h"
#include "Soap/wsdd.nsmap"
#include<string.h>
#define __DEBUG
#ifdef __DEBUG
#define DBG(fmt,args,...) fprintf(stdout, fmt, ##args)
#else
#define DBG(fmt,args,...)
#endif
#define ERR(fmt,args,...) fprintf(stderr, fmt, ##args)
typedef struct _T_SoapInstance {
struct soap *soap;
}SoapInstance;
/*
SOAP初始化
*/
int UserInitSoap()
{
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 = "tds:Device";
result = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
if (result != SOAP_OK) {
printf("soap error!\n");
char p[12] = "";
sprintf_s(p, "%d", soap->error);
MessageBox(NULL,(p), 0, 0);
}
do {
result = soap_recv___wsdd__ProbeMatches(soap, &resp);
if (soap->error)
{
printf("soap error!\n");
result = soap->error;
break;
}
else
{
printf("=================================\n");
printf("%d\n", resp.wsdd__ProbeMatches->__sizeProbeMatch);
printf("%d\n", resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
printf("%s\n", resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item);
printf("QName:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->Types);
printf("xsd:string:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address);
//printf("xsd:QName:%s\n",resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.PortType);
//printf("wsa:ServiceNameType:%s\n"resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.ServiceName);
//printf("sequence of elements:%s\n",resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__size);
printf("xsd:anyType:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__anyAttribute);
//printf("endpoint any:%s\n",resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.__any);
printf("wsdd:UriListType:%s\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs);
printf("============================\n");
}
} while (1);
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
return result;
return 0;
}
/*
SOAP释放
*/
int UserReleaseSoap(struct soap *soap)
{
//soap_free(soap);
soap_destroy(soap);
soap_end(soap);
soap_done(soap);
soap_del(soap);
/*
The gSOAP engine uses a memory management method to allocate and deallocate memory.
The deallocation is performed with soap_destroy() followed by soap_end().
However, when you compile with -DDEBUG or -DSOAP_MEM_DEBUG then no memory
is released until soap_done() is invoked. This ensures that the gSOAP engine
can track all malloced data to verify leaks and double frees in debug mode.
Use -DSOAP_DEBUG to use the normal debugging facilities without memory debugging.
Note that some compilers have DEBUG enabled in the debug configuration, so this behavior
should be expected unless you compile in release config
*/
return 0;
}
OnvifDeviceInfo *Onvif::Device_Detect(void){
return NULL;
}
Onvif::Onvif()
{
}
Onvif::~Onvif()
{
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。