省略:onvif client soapRemoteDiscoveryBindingProxy 由 gsoap C++ 方式生成
十余年的白河网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。网络营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整白河建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“白河网站设计”,“白河网站推广”以来,每个客户项目都认真落实执行。
#include "soapRemoteDiscoveryBindingProxy.h"
#include "RemoteDiscoveryBinding.nsmap"
#include
using namespace std;
SOAP_FMAC5 int SOAP_FMAC6 soap_send___wsdd__Probe(struct soap *soap, const char *soap_endpoint, const char *soap_action, struct wsdd__ProbeType *wsdd__Probe)
{struct __wsdd__Probe soap_tmp___wsdd__Probe;
if (soap_action == NULL)
soap_action = "http://docs.oasis-open.org/ws-dd/ns/discovery/2009/01/Probe";
soap_tmp___wsdd__Probe.wsdd__Probe = wsdd__Probe;
soap_begin(soap);
soap_set_version(soap, 2); /* SOAP1.2 */
soap->encodingStyle = NULL;
soap_serializeheader(soap);
soap_serialize___wsdd__Probe(soap, &soap_tmp___wsdd__Probe);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Probe(soap, &soap_tmp___wsdd__Probe, "-wsdd:Probe", "")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_endpoint, soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put___wsdd__Probe(soap, &soap_tmp___wsdd__Probe, "-wsdd:Probe", "")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
return SOAP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_recv___wsdd__ProbeMatches(struct soap *soap, struct __wsdd__ProbeMatches *_param_1)
{
soap_default___wsdd__ProbeMatches(soap, _param_1);
soap_begin(soap);
if (soap_begin_recv(soap)
|| soap_envelope_begin_in(soap)
|| soap_recv_header(soap)
|| soap_body_begin_in(soap))
return soap_closesock(soap);
soap_get___wsdd__ProbeMatches(soap, _param_1, "-wsdd:ProbeMatches", NULL);
if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
soap->error = SOAP_OK;
if (soap->error
|| soap_body_end_in(soap)
|| soap_envelope_end_in(soap)
|| soap_end_recv(soap))
return soap_closesock(soap);
return soap_closesock(soap);
}
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 = 3; //超过x秒钟没有数据就退出
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 = "dn:NetworkVideoTransmitter";
result = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
int i = 0,nFindDev=0;
while (i++<10)
{
printf("soap_discovery_recv...\n");
result = soap_recv___wsdd__ProbeMatches(soap,&resp);
if (result == SOAP_OK)
{
if (!(soap->header))
{
printf("continue++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
continue;
}
nFindDev++;
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 << "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;
}
else
{
printf("2soap error: %d, %s, %s@@@@@@@@@@@\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
break;
}
}
printf("exit while,find dev:%d\n", nFindDev);
// remove deserialized class instances (C++ only)
soap_destroy(soap);
// clean up and remove deserialized data
soap_end(soap);
////////////////////////////////////////////////////////////////////////////
soap_free(soap);//detach and free runtime context
soap_done(soap); // detach context (last use and no longer in scope)
return result;
}
文章名称:onvifclientDiscovery实现
浏览地址:http://scgulin.cn/article/ipssjo.html