ONVIF GSOAP Development

From ago control wiki
(Difference between revisions)
Jump to: navigation, search
m (Discovery without proxy)
m (discovery with wsdd proxy class)
Line 52: Line 52:
 
=== discovery with wsdd proxy class ===
 
=== discovery with wsdd proxy class ===
 
<pre>
 
<pre>
std::string tmpuuid = "urn:uuid:" +  generateUuid();
+
struct wsdd__ProbeType probe;
 +
struct __wsdd__ProbeMatches matches;
 +
probe.Scopes = new struct wsdd__ScopesType();
 +
probe.Types = (char*)"tdn:NetworkVideoTransmitter";
  
wsddProxy *discoverProxy = new wsddProxy("soap.udp://239.255.255.250:3702/");
+
std::string tmpuuid = "urn:uuid:" +  generateUuid();
discoverProxy->soap_header((char*)tmpuuid.c_str(), NULL, NULL, NULL, NULL, "urn:schemas-xmlsoap-org:ws:2005:04:discovery",
+
 
 +
wsddProxy *discoverProxy = new wsddProxy("soap.udp://239.255.255.250:3702/");
 +
discoverProxy->soap_header((char*)tmpuuid.c_str(), NULL, NULL, NULL, NULL, "urn:schemas-xmlsoap-org:ws:2005:04:discovery",
 
                         "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
                         "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
discoverProxy->recv_timeout=3;
+
discoverProxy->recv_timeout=3;
  
printf("Sending probe\n");
+
printf("Sending probe\n");
discoverProxy->send_Probe(&probe);
+
discoverProxy->send_Probe(&probe);
printf("waiting for matches\n");
+
printf("waiting for matches\n");
while ( discoverProxy->recv_ProbeMatches(matches) == SOAP_OK) {
+
while ( discoverProxy->recv_ProbeMatches(matches) == SOAP_OK) {
printf("Service Addr: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->XAddrs);
+
printf("Service Addr: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->XAddrs);
//printf("Type: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->Types);
+
//printf("Type: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->Types);
//printf("Metadata Ver: %d\n",matches.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
+
//printf("Metadata Ver: %d\n",matches.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
}
+
}
discoverProxy->destroy();
+
discoverProxy->destroy();
 
</pre>
 
</pre>

Revision as of 23:24, 30 July 2013

Discovery without proxy class

	/*
	struct soap *soap;
	struct wsdd__ProbeType probeType;
	struct __wsdd__ProbeMatches matches;
	struct wsdd__ScopesType scopesType;
	struct SOAP_ENV__Header header;

	char uuid_string[37];
	std::string tmpuuid = "urn:uuid:" +  generateUuid();
	printf("tmpuuid: %s\n", tmpuuid.c_str());
	strncpy (uuid_string, tmpuuid.c_str(), 37);

	soap = soap_new();
	if(soap==NULL) {
		printf("ERROR: Can't initalize soap\n");
		return -1;
	}

	soap_set_namespaces(soap, namespaces);
	soap->recv_timeout=5;

	// set header
	soap_default_SOAP_ENV__Header(soap, &header);
	header.wsa__MessageID = uuid_string;
	header.wsa__To = (char *)"urn:schemas-xmlsoap-org:ws:2005:04:discovery";
	header.wsa__Action = (char *)"http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe";
	soap->header = &header;

	soap_default_wsdd__ScopesType (soap, &scopesType);
	scopesType.__item = (char *)"onvif://www.onvif.org";
	soap_default_wsdd__ProbeType(soap, &probeType);
	probeType.Scopes = &scopesType;

	probeType.Types = (char *)"tdn:NetworkVideoTransmitter";

	if (soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702/", NULL, &probeType) == -1) {
		printf("SOAP error occured: %d %s - %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
		return soap->error;
	} else {
		while (soap_recv___wsdd__ProbeMatches(soap, &matches) != -1) {
			printf("match size: %d\n",matches.wsdd__ProbeMatches->__sizeProbeMatch);
			printf("Endpoint Addr: %s\n",matches.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address);
			printf("Service Addr: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->XAddrs);
			printf("Type: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->Types);
			printf("Metadata Ver: %d\n",matches.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
			printf("Scopes Addr: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->Scopes->__item);
		}
	} */

discovery with wsdd proxy class

	struct wsdd__ProbeType probe;
	struct __wsdd__ProbeMatches matches;
	probe.Scopes = new struct wsdd__ScopesType();
	probe.Types = (char*)"tdn:NetworkVideoTransmitter";

	std::string tmpuuid = "urn:uuid:" +  generateUuid();

	wsddProxy *discoverProxy = new wsddProxy("soap.udp://239.255.255.250:3702/");
	discoverProxy->soap_header((char*)tmpuuid.c_str(), NULL, NULL, NULL, NULL, "urn:schemas-xmlsoap-org:ws:2005:04:discovery",
                        "http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	discoverProxy->recv_timeout=3;

	printf("Sending probe\n");
	discoverProxy->send_Probe(&probe);
	printf("waiting for matches\n");
	while ( discoverProxy->recv_ProbeMatches(matches) == SOAP_OK) {
		printf("Service Addr: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->XAddrs);
		//printf("Type: %s\n", matches.wsdd__ProbeMatches->ProbeMatch->Types);
		//printf("Metadata Ver: %d\n",matches.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
	}
	discoverProxy->destroy();
Personal tools