onvif客户端demo
#include “OnvifAPIAll/DeviceBinding.nsmap“
#include “OnvifAPIAll/wsseapi.h“
#include “OnvifAPIAll/wsaapi.h“
#include “OnvifAPIAll/soapDeviceBindingProxy.h“
#include “OnvifAPIAll/soapMediaBindingProxy.h“
#include “OnvifAPIAll/soapPTZBindingProxy.h“
#include “OnvifAPIAll/soapEventBindingProxy.h“
#include “OnvifAPIAll/soapNotificationProducerBindingProxy.h“
#include “OnvifAPIAll/soapDiscoveryLookupBindingProxy.h“
using namespace std;
#pragma comment(lib“Rpcrt4.lib“)
#define DEV_PASSWORD “admin“
#define MAX_HOSTNAME_LEN 128
void PrintErr(struct soap* _psoap)
{
fflush(stdout);
fprintf(stdout“error:%d faultstring:%s faultcode:%s faultsubcode:%s faultdetail:%s\r\n“_psoap->error*soap_faultstring(_psoap)*soap_faultcode(_psoap)
*soap_faultsubcode(_psoap)*soap_faultdetail(_psoap));
}
int _tmain(int argc char* argv[])
{
bool blSupportPTZ = false;
char szHostName[MAX_HOSTNAME_LEN] = {0};
DeviceBinding proxyDevice;
MediaBinding proxyMedia;
PTZBinding proxyPTZ;
EventBinding proxyEvent;
NotificationProducerBinding proxyNP;
if (argc > 1)
{
strcat(szHostName“http://“);
strcat(szHostNameargv[1]);
strcat(szHostName“/onvif/device_service“);
proxyDevice.endpoint = szHostName;
}
else
{
proxyDevice.endpoint = “http://172.16.12.197/onvif/device_service“;
}
/*soap_register_plugin(proxyDevice.soapsoap_wsse);
soap_register_plugin(proxyMedia.soapsoap_wsse);
soap_register_plugin(proxyPTZ.soapsoap_wsse);
soap_register_plugin(proxyEvent.soapsoap_wsse);
soap_register_plugin(proxyNP.soapsoap_wsse);
soap_register_plugin(proxyEvent.soapsoap_wsa);
soap_register_plugin(proxyNP.soapsoap_wsa);*/
struct soap *soap = soap_new();
//if(SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyDevice.soap NULL “admin“ DEV_PASSWORD))
//{
// return -1;
//}
//if(SOAP_OK != soap_wsse_add_Timestamp(proxyDevice.soap “Time“ 10)) // 10 seconds lifetime
//{
// return -1;
//}
#if 1
//Get WSDL URL
_tds__GetWsdlUrl *tds__GetWsdlUrl = soap_new__tds__GetWsdlUrl(soap-1);
_tds__GetWsdlUrlResponse *tds__GetWsdlUrlResponse = soap_new__tds__GetWsdlUrlResponse(soap-1);
if(SOAP_OK == proxyDevice.__tds__GetWsdlUrl(tds__GetWsdlUrltds__GetWsdlUrlResponse))
{
//fflush(stdout);
fprintf(stdout“-------------------WsdlUrl-------------------\r\n“);
fprintf(stdout“WsdlUrl:%s\r\n “tds__GetWsdlUrlResponse->WsdlUrl.c_str());
}
else
{
PrintErr(proxyDevice.soap);
}
soap_destroy(soap); // remove deserialized class instances (C++ only)
soap_end(soap); // clean up and remove deserialized data
#endif
/*if(SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyDevice.soap NULL “admin“ DEV_PASSWORD))
{
return -1;
}*/
//Capability exchange
_tds__GetCapabilities *tds__GetCapabilities = soap_new__tds__