ONVIF GSOAP Development

From ago control wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "=== Discovery without proxy === <pre> /* struct soap *soap; struct wsdd__ProbeType probeType; struct __wsdd__ProbeMatches matches; struct wsdd__ScopesType scopesType; st...")
 
m (Discovery without proxy)
Line 1: Line 1:
=== Discovery without proxy ===
+
=== Discovery without proxy class ===
 
<pre>
 
<pre>
 
/*
 
/*
Line 49: Line 49:
 
}
 
}
 
} */
 
} */
 +
</pre>
 +
=== discovery with wsdd proxy class ===
 +
<pre>
 +
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();
 
</pre>
 
</pre>

Revision as of 00:23, 31 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

		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