Exemplo n.º 1
0
void *process_request(void *soap)
{ pthread_detach(pthread_self());
  /* Serve request (or multiple requests with keep-alive enabled) */
  soap_serve((struct soap*)soap);
  /* Cleanup and delete deserialized data */
  soap_destroy((struct soap*)soap);
  soap_end((struct soap*)soap);
  /* Detach thread's copy of soap environment */
  soap_done((struct soap*)soap);
  /* Free soap environment */
  free(soap);
  fprintf(stderr, "done\n");
  return NULL;
}
Exemplo n.º 2
0
void TCSoapRunnable::process_message(ACE_Message_Block* mb)
{
    ACE_TRACE (ACE_TEXT ("SOAPWorkingThread::process_message"));

    struct soap* soap;
    ACE_OS::memcpy(&soap, mb->rd_ptr (), sizeof(struct soap*));
    mb->release();

    soap_serve(soap);
    soap_destroy(soap); // dealloc C++ data
    soap_end(soap); // dealloc data and clean up
    soap_done(soap); // detach soap struct
    free(soap);
}
int main(int argc, char **argv)
{ struct soap soap;
  // use HTTP 1.1 chunking
  // HTTP chunking allows streaming of DIME content without requiring DIME attachment size to be set
  // DIME attachments can be streamed without chunking ONLY if the attachment size is set
  soap_init1(&soap, SOAP_IO_CHUNK);
  // set DIME callbacks
  soap.fdimereadopen = dime_read_open;
  soap.fdimereadclose = dime_read_close;
  soap.fdimeread = dime_read;
  soap.fdimewriteopen = dime_write_open;
  soap.fdimewriteclose = dime_write_close;
  soap.fdimewrite = dime_write;
  // connect timeout value (not supported by Linux)
  soap.connect_timeout = 10;
  // IO timeouts
  soap.send_timeout = 30;
  soap.recv_timeout = 30;
  // Unix/Linux SIGPIPE, this is OS dependent:
  // soap.accept_flags = SO_NOSIGPIPE;	// some systems like this
  // soap.socket_flags = MSG_NOSIGNAL;	// others need this
  // signal(SIGPIPE, sigpipe_handle);	// or a sigpipe handler (portable)
  if (argc < 3)
  { char *name;
    if (argc < 2)
      name = "image.jpg";
    else
      name = argv[1];
    getImage(&soap, name);
  }
  else
  { switch (argv[1][1])
    { case 'p':
	endpoint = localhost;
        putData(&soap, argc, argv);
        break;
      case 'g':
	endpoint = localhost;
        getData(&soap, argc, argv);
        break;
      default:
        fprintf(stderr, "Usage: [-p] [-g] name ...\n");
	exit(0);
    }
  }
  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);
  return SOAP_OK;
}
int ConsoleObserverService::run(int port)
{	if (soap_valid_socket(bind(NULL, port, 100)))
	{	for (;;)
		{	if (!soap_valid_socket(accept()))
				return this->error;
			(void)serve();
			soap_destroy(this);
			soap_end(this);
		}
	}
	else
		return this->error;
	return SOAP_OK;
}
Exemplo n.º 5
0
void grisu_stop(void)
{
/* grisu */
g_free(grisu_username);
g_free(grisu_password);
g_free(grisu_server);
g_free(grisu_port);
g_free(grisu_soap_header);
g_free(grisu_cert_path);

/* soap */
soap_destroy(&soap); 
soap_end(&soap); 
soap_done(&soap); 
}
Exemplo n.º 6
0
int main(int argc, char **argv)
{ struct soap *soap = soap_new();
  float q;
  if (argc <= 2)
  { soap->user = soap_new(); // pass a new gSOAP environment which we need to make server-side client calls
    soap_serve(soap);	// serve request
    soap_destroy((struct soap*)soap->user);
    soap_end((struct soap*)soap->user);
    soap_done((struct soap*)soap->user);
    free(soap->user);
    soap->user = NULL;
  }
  else if (soap_call_ns3__getQuote(soap, endpoint, NULL, argv[1], argv[2], q) == 0)
    printf("\nCompany %s: %f (%s)\n", argv[1], q, argv[2]);
  else
  { soap_print_fault(soap, stderr);
    soap_print_fault_location(soap, stderr);
  }
  soap_destroy(soap);
  soap_end(soap);
  soap_done(soap);
  free(soap);
  return 0;
}
Exemplo n.º 7
0
void *process_queue(void *soap)
{
    struct soap *tsoap = (struct soap*)soap;
    for (;;)
    {
        tsoap->socket = dequeue();
        if (!soap_valid_socket(tsoap->socket))
            break;
        soap_serve(tsoap);
        soap_destroy(tsoap);
        soap_end(tsoap);
        fprintf(stderr, "served\n");
    }
    return NULL;
}
Exemplo n.º 8
0
void glite_delegation_free(glite_delegation_ctx *ctx)
{
    if(!ctx)
        return;

    free(ctx->endpoint);
    free(ctx->error_message);
    if(ctx->soap) 
    {
        soap_destroy(ctx->soap);
        soap_end(ctx->soap);
        free(ctx->soap);
    }
    free(ctx);
}
Exemplo n.º 9
0
int main(int argc, char **argv)
{ int m, s;
  struct soap soap;
  soap_init(&soap);
  // cookie domain for CGI must be the current host name:
  // soap.cookie_domain = "www.cs.fsu.edu";
  // Cookie domain for stand-alone server:
  soap.cookie_domain = "localhost:8080";
  // the path which is used to filter/set cookies with this destination
  soap.cookie_path = "/";
  if (argc < 2)
  { // CGI app: grab cookies from 'HTTP_COOKIE' env var
    soap_getenv_cookies(&soap);
    soap_serve(&soap);
  }
  else
  { int port;
    char buf[100];
    port = atoi(argv[1]);
    m = soap_bind(&soap, NULL, port, 100);
    if (m < 0)
    { soap_print_fault(&soap, stderr);
      exit(1);
    }
    sprintf(buf, "localhost:%d", port);
    soap.cookie_domain = buf;
    fprintf(stderr, "Socket connection successful %d\n", m);
    for (int i = 1; ; i++)
    { s = soap_accept(&soap);
      if (s < 0)
        exit(-1);
      fprintf(stderr, "%d: accepted %d IP=%d.%d.%d.%d ... ", i, s, (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
      if (!soap_serve(&soap))
        fprintf(stderr, "served\n");
      else
        soap_print_fault(&soap, stderr);
      // clean up 
      soap_destroy(&soap);
      soap_end(&soap);
      // remove all old cookies from database so no interference when new
      // requests with new cookies arrive
      soap_free_cookies(&soap);
      // Note: threads can have their own cookie DB which they need to cleanup
      // before they terminate
    }
  }
  return 0;
}
Exemplo n.º 10
0
int OnvifClientPTZ::getConfiguration(std::string configurationToken){
	if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())){
		return -1;
	}

	_tptz__GetConfiguration *tptz__GetConfiguration = soap_new__tptz__GetConfiguration(soap,-1);
	_tptz__GetConfigurationResponse *tptz__GetConfigurationResponse = soap_new__tptz__GetConfigurationResponse(soap,-1);

	tptz__GetConfiguration->PTZConfigurationToken = configurationToken;



	if(SOAP_OK == proxyPTZ.GetConfiguration(tptz__GetConfiguration, tptz__GetConfigurationResponse)){
		std::cout << std::endl;
		std::cout << "Absolute Pan Tilt Position Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultAbsolutePantTiltPositionSpace->	c_str() << std::endl;
		std::cout << "Absolute Zoom Position Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultAbsoluteZoomPositionSpace->	c_str() << std::endl;
		std::cout << "Relative Pan Tilt Translation Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultRelativeZoomTranslationSpace->c_str() << std::endl;
		std::cout << "Relative Zoom Translation Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultContinuousPanTiltVelocitySpace->c_str() << std::endl;
		std::cout << "Continuous Pan Tilt Velocity Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultContinuousZoomVelocitySpace->c_str() << std::endl;
		std::cout << "Continuous Zoom Velocity Space: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultContinuousZoomVelocitySpace->c_str() << std::endl << std::endl;
		
		printf("Default PTZ Timeout: %ds\n", *tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZTimeout/1000);

		printf("Pan Min Limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->XRange->Min);
		printf("Pan Max Limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->XRange->Max);

		printf("Tilt Min limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->YRange->Min);
		printf("Tilt Max limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->YRange->Max);
		std::cout << "Coordinate System: " << tptz__GetConfigurationResponse->PTZConfiguration->PanTiltLimits->Range->URI.c_str() << std::endl;
		std::cout << std::endl;

		printf("Zoom Min limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->ZoomLimits->Range->XRange->Min);
		printf("Zoom Max limit: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->ZoomLimits->Range->XRange->Max);


		printf("Default Pan Speed: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->PanTilt->x);
		printf("Default Tilt Speed: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->PanTilt->y);
		std::cout << "Coordinate System: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->PanTilt->space->c_str() << std::endl;
		printf("Default Zoom Speed: %f\n", tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->Zoom->x);
		std::cout << "Coordinate System: " << tptz__GetConfigurationResponse->PTZConfiguration->DefaultPTZSpeed->Zoom->space->c_str() << std::endl;
		std::cout << std::endl << std::endl;
	}else{
		//PrintErr(proxyPTZ.soap);
	}

	soap_destroy(soap); 
	soap_end(soap);
}
Exemplo n.º 11
0
inline void innersimpleGsoap2()
{
	struct soap *soap = soap_new();
	soap_init(soap);
	soap_set_omode(soap, SOAP_XML_GRAPH);
	soap_imode(soap, SOAP_XML_GRAPH);
	soap_begin(soap);

	_ns1__outersimpleGsoap2 input, output;
	input.soap = soap;

	ns1__innersimpleGsoap2 inner1;
	inner1.soap = soap;
	inner1.att1 = 1;
	inner1.att2 = 2;

	ns1__innersimpleGsoap2 inner2;
	inner2.soap = soap;
	inner2.att1 = 1;
	inner2.att2 = 2;

	input.att1 = &inner1;
	input.att2 = &inner2;

	boost::asio::streambuf streambuf;
	std::ostream *ost = new std::ostream(&streambuf);
	std::istream *ist = new std::istream(&streambuf);
	input.soap->os = ost;
	input.soap->is = ist;

	boost::timer::auto_cpu_timer t;

	for(int i=0; i < NUMBER_OF_LOOPS; ++i){
		soap_write__ns1__outersimpleGsoap2(soap, &input);

		//streambuf.pubseekpos(0);
		//ost->rdbuf(&streambuf);
		//std::cout << "Str: " << streambuf.size() << endl;
		//break;

		soap_read__ns1__outersimpleGsoap2(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Exemplo n.º 12
0
inline void complexGsoap2()
{
	struct soap *soap = soap_new();
	soap_init(soap);
	soap_set_omode(soap, SOAP_XML_GRAPH);
	soap_imode(soap, SOAP_XML_GRAPH);
	soap_begin(soap);

	_ns1__complexGsoap2 input, output;
	input.soap = soap;
	input.att1 = 0;
	input.att2 = 1;
	input.att3 = 0;
	input.att4 = 1;
	input.att5 = "TEST 0";
	input.att6 = "TEST 1";
	input.att7 = 2.5;
	input.att8 = 3.6;
	input.att9 = 27.1;
	input.att10 = 28.2;
	input.att11 = true;
	input.att12 = true;

	boost::asio::streambuf streambuf;
	std::ostream *ost = new std::ostream(&streambuf);
	std::istream *ist = new std::istream(&streambuf);
	input.soap->os = ost;
	input.soap->is = ist;

	boost::timer::auto_cpu_timer t;

	for(int i=0; i < NUMBER_OF_LOOPS; ++i){
		soap_write__ns1__complexGsoap2(soap, &input);

		//streambuf.pubseekpos(0);
		//ost->rdbuf(&streambuf);
		//std::cout << "Str: " << streambuf.size() << endl;
		//break;

		soap_read__ns1__complexGsoap2(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Exemplo n.º 13
0
static void *_working_proc(void *param)
#endif // win32
{
    struct soap *soap = (struct soap*)param;
    
#ifdef WIN32
#else
    pthread_detach(pthread_self());
#endif//
    soap_serve((struct soap*)soap);
    soap_destroy((struct soap*)soap); // dealloc C++ data
    soap_end((struct soap*)soap); // dealloc data and clean up
    soap_done((struct soap*)soap); // detach soap struct
    soap_free(soap);
    
    return NULL;
}
Exemplo n.º 14
0
void send(const std::string& message)
{
	struct soap account_info_soap;
	

	soap_init(&account_info_soap);

	if (soap_ssl_client_context(&account_info_soap,
		SOAP_SSL_DEFAULT | SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE,
		"client.key", /* keyfile: required only when client must authenticate to server (see SSL docs on how to obtain this file) */
		NULL, /* password to read the key file (not used with GNUTLS) */
		"server.crt", /* cacert file to store trusted certificates (needed to verify server) */
		NULL, /* capath to directory with trusted certificates */
		NULL /* if randfile!=NULL: use a file with random data to seed randomness */
	))
	{
		printf("Init soap ssl client context error \n");
		return;
	}


	std::string server = "https://172.18.15.7/pmec/mid/trade/";
	std::string result;
	account_info_soap.userid = "1";
	account_info_soap.passwd = "cpp";
	account_info_soap.connect_timeout = 60;	/* try to connect for 1 minute */
	account_info_soap.send_timeout = account_info_soap.recv_timeout = 30;	/* if I/O stalls, then timeout after 30 seconds */

	if (soap_call_ns__trade(&account_info_soap, server.c_str(), NULL, message, &result) == SOAP_OK)
	{
		printf("result is %s, thread id = %lu\n", result.c_str(), pthread_self());
	}
	else
	{
		soap_print_fault(&account_info_soap, stderr);
	}

	soap_destroy(&account_info_soap); /* C++ */
	soap_end(&account_info_soap);
	soap_done(&account_info_soap);
	
	//soap_free(&account_info_soap);
	
	usleep(1);
}
Exemplo n.º 15
0
int ONVIF_SEARCH_GetServiceCapabilities(char *username, char *password, char *searchService)
{
    int retval = 0;
    struct soap *soap = NULL;
    
    struct _tse__GetServiceCapabilities search_GetServiceCapabilities_req;
    struct _tse__GetServiceCapabilitiesResponse search_GetServiceCapabilities_resp;

        
    struct SOAP_ENV__Header header;

    UserInfo_S stUserInfo;
    memset(&stUserInfo, 0, sizeof(UserInfo_S));
 
    strcpy(stUserInfo.username, username);
    strcpy(stUserInfo.password, password);
        
    memset(&header,0,sizeof(header));
    soap = ONVIF_Initsoap(&header, NULL, NULL, 5, &stUserInfo);
    char *soap_endpoint = (char *)malloc(256);
    memset(soap_endpoint, '\0', 256);
    
    sprintf(soap_endpoint, "%s", searchService);
    const char *soap_action = "http://www.onvif.org/ver20/search/wsdl/GetServiceCapabilities";

    do
    {
        soap_call___tse__GetServiceCapabilities(soap, soap_endpoint, soap_action, &search_GetServiceCapabilities_req, &search_GetServiceCapabilities_resp);
        if (soap->error)
        {
                printf("[%s][%d]--->>> soap error: %d, %s, %s\n", __func__, __LINE__, soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
                retval = soap->error;
                return retval;
        }
        else  
        {         
              printf("[%s][%d]   success !\n", __func__, __LINE__);
        }
    }while(0);

    free(soap_endpoint);
    soap_endpoint = NULL;
    soap_destroy(soap);
    return retval;
}
Exemplo n.º 16
0
int main()
{ struct soap soap;
  init_received();
  soap_init1(&soap, SOAP_IO_UDP);
  if (!soap_valid_socket(soap_bind(&soap, NULL, 10000, 100)))
  { soap_print_fault(&soap, stderr);
    exit(1);
  }
  for (;;)
  { printf("Accepting requests...\n");
    if (soap_serve(&soap))
      soap_print_fault(&soap, stderr);
    soap_destroy(&soap);
    soap_end(&soap);
  }
  soap_done(&soap);
  return 0;
}
Exemplo n.º 17
0
inline void simpleGsoap10()
{
	struct soap *soap = soap_new();
	soap_init(soap);
	soap_set_omode(soap, SOAP_XML_GRAPH);
	soap_imode(soap, SOAP_XML_GRAPH);
	soap_begin(soap);

	_ns1__simpleGsoap10 input, output;
	input.soap = soap;
	input.att1 = 1;
	input.att2 = 2;
	input.att3 = 3;
	input.att4 = 4;
	input.att5 = 5;
	input.att6 = 6;
	input.att7 = 7;
	input.att8 = 8;
	input.att9 = 9;
	input.att10 = 10;

	boost::asio::streambuf streambuf;
	std::ostream *ost = new std::ostream(&streambuf);
	std::istream *ist = new std::istream(&streambuf);
	input.soap->os = ost;
	input.soap->is = ist;

	boost::timer::auto_cpu_timer t;

	for(int i=0; i < NUMBER_OF_LOOPS; ++i){
		soap_write__ns1__simpleGsoap10(soap, &input);
		
		//streambuf.pubseekpos(0);
		//ost->rdbuf(&streambuf);
		//std::cout << "Str: " << streambuf.size() << endl;
		//break;
		
		soap_read__ns1__simpleGsoap10(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Exemplo n.º 18
0
void *process_request(void *soap)
{


#ifdef _POSIX_THREADS
	pthread_detach(pthread_self());
#endif
	soap_ssl_accept((struct soap*)soap);

	// serve request (or multiple requests with keep-alive enabled)
	soap_serve((struct soap*)soap);
	// cleanup class instances
	soap_destroy((struct soap*)soap);
	// cleanup
	soap_end((struct soap*)soap);
	// detach and free thread's copy of soap environment
	soap_free((struct soap*)soap);
	return NULL;
}
Exemplo n.º 19
0
static DSL_int_t DSL_CPE_SOAP(DSL_CPE_Thread_Params_t *param)
{
   Soap_env_t *pSoapEnv = (Soap_env_t *)param->nArg1;
   int s;    /* slave socket */
   int ret = 0;
   pSoapEnv->pid = DSL_CPE_ThreadIdGet();
   pSoapEnv->server.soap.user = (DSL_void_t *)pSoapEnv;

   if ( ((Soap_env_t *)param->nArg1) == DSL_NULL)
   {
      return -1;
   }

   while (pSoapEnv->bRun)
   {
      s = soap_accept (&pSoapEnv->server.soap);
      if ( s < 0 )
      {
         if (pSoapEnv->bRun == 0)
            break;
         /* timeout -> continue */
         /*DSL_CCA_DEBUG(DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX
            "SOAP socket time out (error %d)" DSL_CPE_CRLF, s));*/
         continue;
      }

      if (soap_serve(&pSoapEnv->server.soap) != SOAP_OK) /* process RPC request */
      {
         /*soap_print_fault(&pSoapEnv->server.soap, stderr);*/ /* print error */
      }

      soap_destroy (&pSoapEnv->server.soap); /* clean up class instances */
      soap_end (&pSoapEnv->server.soap);
   }

   soap_end(&pSoapEnv->server.soap);

   soap_done(&pSoapEnv->server.soap); /* close master socket and detach environment */

   pSoapEnv->pid = 0;

   return ret;
}
Exemplo n.º 20
0
void audioDB::ws_liszt(const char* dbName, char* Hostport){
  struct soap soap;
  adb__lisztResponse adbLisztResponse;

  soap_init(&soap);
  if(soap_call_adb__liszt(&soap, hostport, NULL, (char*)dbName, lisztOffset, lisztLength, adbLisztResponse)==SOAP_OK){
    for(int i = 0; i < adbLisztResponse.result.__sizeRkey; i++) {
      std::cout << "[" << i+lisztOffset << "] " << adbLisztResponse.result.Rkey[i] << " (" 
		<< adbLisztResponse.result.Rlen[i] << ")" << std::endl;
    }
  } else {
    char fault[MAXSTR];
    soap_sprint_fault(&soap, fault, MAXSTR);
    error(fault);
  }
  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);
}
Exemplo n.º 21
0
int OnvifClientPTZ::getPTZConfigurations(){
	if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())){
		return -1;
	}

	_tptz__GetConfigurations *tptz__GetConfigurations = soap_new__tptz__GetConfigurations(soap, -1);
	_tptz__GetConfigurationsResponse *tptz__GetConfigurationsResponse = soap_new__tptz__GetConfigurationsResponse(soap, -1);

	if(SOAP_OK == proxyPTZ.GetConfigurations(tptz__GetConfigurations, tptz__GetConfigurationsResponse)){
		for(int i = 0; i<tptz__GetConfigurationsResponse->PTZConfiguration.size(); ++i){
			std::cout << "ConfigurationToken #" << i << ": " << tptz__GetConfigurationsResponse->PTZConfiguration[i]->token << std::endl;
		}
	}else{
		//PrintErr(proxyPTZ.soap);
	}

	soap_destroy(soap); 
	soap_end(soap);
}
Exemplo n.º 22
0
int OnvifClientPTZ::goToHomePosition(std::string profileToken){
	if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str())){
		return -1;
	}

	_tptz__GotoHomePosition *tptz__GotoHomePosition = soap_new__tptz__GotoHomePosition(soap, -1);
	_tptz__GotoHomePositionResponse *tptz__GotoHomePositionResponse = soap_new__tptz__GotoHomePositionResponse(soap, -1);

	tptz__GotoHomePosition->ProfileToken = profileToken;

	if(SOAP_OK == proxyPTZ.GotoHomePosition(tptz__GotoHomePosition, tptz__GotoHomePositionResponse)){

	}else{
		//PrintErr(proxyPTZ.soap);
	}

	soap_destroy(soap); 
	soap_end(soap);
}
Exemplo n.º 23
0
static int getImage(const char *name, const char *url, const char *outputfile) {
	struct soap soap;
	xsd__base64Binary image;
	soap_init(&soap);
    soap.user = (void*)outputfile;
    soap.fdimewriteopen = dime_write_open;
    soap.fdimewriteclose = dime_write_close;
    soap.fdimewrite = dime_write;
	soap.connect_timeout = 10;
	int nRet = soap_call_ns__getImage(&soap, url, "", (char *)name, image);
	if (nRet != SOAP_OK) {
		soap_print_fault(&soap, stderr);
	} else {
		printf("got an image, I suppose\n");
	}
	soap_destroy(&soap);
	soap_end(&soap);
	return nRet;
}
int OnvifRemoteDiscoveryBindingService::run(int port)
{
	if (soap_valid_socket(this->master) || bind(port))
	{
		for (;;)
		{
			if (!soap_valid_socket(accept()))
				return this->error;
			if (serve())
				return this->error;
			soap_destroy(this);
			soap_end(this);
		}
	}
	else {
		return this->error;
	}
	return SOAP_OK;
}
Exemplo n.º 25
0
int main(int argc, char * argv[]) {
	SOAP_SOCKET m, s;
	struct soap soap;

	soap_init1(&soap, SOAP_IO_UDP);

	m = soap_bind(&soap, NULL,  PORT, 100);
 	/* reuse address */
 	soap.bind_flags = SO_REUSEADDR;
	if (!soap_valid_socket(m)) {
		soap_print_fault(&soap, stderr);
		exit(-1);
	}
	/* optionally join a multicast group */
	if (MULTICAST_GROUP) { 
		struct ip_mreq mreq;
		mreq.imr_multiaddr.s_addr = inet_addr(MULTICAST_GROUP);
		mreq.imr_interface.s_addr = htonl(INADDR_ANY);
		if (setsockopt(soap.socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
			printf("setsockopt failed\n");
	      		exit(-1);
		}
	}
	printf("socket bind success %d\n", m);
	for (;;) {
		printf("socket connect %d\n", s);
		s = soap_accept(&soap);
		if (!soap_valid_socket(s)) {
			soap_print_fault(&soap, stderr);
			exit(-1);
		}
		if (soap_serve(&soap) != SOAP_OK) {
			soap_print_fault(&soap, stderr);
		}
		soap_destroy(&soap);
		soap_end(&soap);
		
	}

	soap_done(&soap);
	return 0;
}
Exemplo n.º 26
0
int run_client(int argc, char **argv)
{ struct soap soap;
  int ret = 0;
#ifdef WITH_GZIP
  soap_init1(&soap, SOAP_ENC_MTOM | SOAP_ENC_ZLIB); /* Enable MTOM */
#else
  soap_init1(&soap, SOAP_ENC_MTOM); /* Enable MTOM */
#endif
  /* Set the MIME callbacks */
  soap.fmimereadopen = mime_read_open;
  soap.fmimereadclose = mime_read_close;
  soap.fmimeread = mime_read;
  soap.fmimewriteopen = mime_client_write_open;
  soap.fmimewriteclose = mime_client_write_close;
  soap.fmimewrite = mime_client_write;
  /* Connect timeout value (sec) (not supported by Linux) */
  soap.connect_timeout = 10;
  /* IO timeouts (sec) */
  soap.send_timeout = 30;
  soap.recv_timeout = 30;
  /* Unix/Linux SIGPIPE, this is OS dependent:
  soap.accept_flags = SO_NOSIGPIPE;	// some systems like this
  soap.socket_flags = MSG_NOSIGNAL;	// others need this
  signal(SIGPIPE, sigpipe_handle);	// or a sigpipe handler (more portable)
  */
  switch (argv[1][1])
  { case 'p':
      ret = client_putData(&soap, argc, argv);
      break;
    case 'g':
      ret = client_getData(&soap, argc, argv);
      break;
    default:
      fprintf(stderr, "Usage: mtom-stream-test -p file1 file2 file3 ...\n");
      fprintf(stderr, "       mtom-stream-test -g key1 key2 key3 ...\n");
  }
  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);
  return ret;
}
Exemplo n.º 27
0
int main(int argc, char **argv)
{ struct soap soap;
  double a, b, result;
  if (argc < 4)
  { fprintf(stderr, "Usage: [add|sub|mul|div|pow] num num\n");
    exit(0);
  }
  soap_init1(&soap, SOAP_XML_INDENT);
  a = strtod(argv[2], NULL);
  b = strtod(argv[3], NULL);
  switch (*argv[1])
  { case 'a':
      soap_call_ns__add(&soap, server, "", a, b, &result);
      break;
    case 's':
      soap_call_ns__sub(&soap, server, "", a, b, &result);
      break;
    case 'm':
      soap_call_ns__mul(&soap, server, "", a, b, &result);
      break;
    case 'd':
      soap_call_ns__div(&soap, server, "", a, b, &result);
      break;
    case 'p':
      soap_call_ns__pow(&soap, server, "", a, b, &result);
      break;
    default:
      fprintf(stderr, "Unknown command\n");
      exit(0);
  }
  if (soap.error)
  { soap_print_fault(&soap, stderr);
    exit(1);
  }
  else
    printf("result = %g\n", result);
  soap_destroy(&soap);
  soap_end(&soap);
  soap_done(&soap);
  return 0;
}
Exemplo n.º 28
0
int OnvifClientPTZ::absoluteMove(std::string profileToken, float pan, float panSpeed, float tilt, float tiltSpeed, float zoom, float zoomSpeed){
	if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str()))
	{
		return -1;
	}

	_tptz__AbsoluteMove *tptz__AbsoluteMove = soap_new__tptz__AbsoluteMove(soap, -1);
	_tptz__AbsoluteMoveResponse *tptz__AbsoluteMoveResponse = soap_new__tptz__AbsoluteMoveResponse(soap, -1);

	tptz__AbsoluteMove->ProfileToken = profileToken;

	//setting pan and tilt
	tptz__AbsoluteMove->Position = soap_new_tt__PTZVector(soap, -1);
	tptz__AbsoluteMove->Position->PanTilt = soap_new_tt__Vector2D(soap, -1);
	tptz__AbsoluteMove->Speed = soap_new_tt__PTZSpeed(soap, -1);
	tptz__AbsoluteMove->Speed->PanTilt = soap_new_tt__Vector2D(soap, -1);
	//pan
	tptz__AbsoluteMove->Position->PanTilt->x = pan;
	tptz__AbsoluteMove->Speed->PanTilt->x = panSpeed;
	//tilt
	tptz__AbsoluteMove->Position->PanTilt->y = tilt;
	tptz__AbsoluteMove->Speed->PanTilt->y = tiltSpeed;
	//setting zoom
	tptz__AbsoluteMove->Position->Zoom = soap_new_tt__Vector1D(soap, -1);
	tptz__AbsoluteMove->Speed->Zoom = soap_new_tt__Vector1D(soap, -1);
	tptz__AbsoluteMove->Position->Zoom->x = zoom;
	tptz__AbsoluteMove->Speed->Zoom->x = zoomSpeed;

	if(SOAP_OK == proxyPTZ.AbsoluteMove(tptz__AbsoluteMove, tptz__AbsoluteMoveResponse)){
	
	}else{
		std::cout << "AbsoluteMove ERROR:" << std::endl;
		//PrintErr(proxyPTZ.soap);
		std::cout << std::endl;
	}

	soap_destroy(soap); 
	soap_end(soap);
}
Exemplo n.º 29
0
int OnvifClientPTZ::getStatus(std::string profileToken){
	if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str()))
	{
		return -1;
	}

	_tptz__GetStatus *tptz__GetStatus = soap_new__tptz__GetStatus(soap, -1);
	_tptz__GetStatusResponse *tptz__GetStatusResponse = soap_new__tptz__GetStatusResponse(soap, -1);

	tptz__GetStatus->ProfileToken = profileToken.c_str();
	
	if(SOAP_OK == proxyPTZ.GetStatus(tptz__GetStatus, tptz__GetStatusResponse)){
		std::cout << "PAN: " << tptz__GetStatusResponse->PTZStatus->Position->PanTilt->x << std::endl << "TILT: " <<tptz__GetStatusResponse->PTZStatus->Position->PanTilt->y << std::endl;
		std::cout << "ZOOM:" << tptz__GetStatusResponse->PTZStatus->Position->Zoom->x << std::endl;

		//std::cout << "PanTilt:" << tptz__GetStatusResponse->PTZStatus->MoveStatus->PanTilt << std::endl << "ZoomStatus" << tptz__GetStatusResponse->PTZStatus->MoveStatus->Zoom << std::endl << "ERROR: " << tptz__GetStatusResponse->PTZStatus->Error << std::endl << "UtcTime: " << tptz__GetStatusResponse->PTZStatus->UtcTime << std::endl;
	}else{
		//PrintErr(proxyPTZ.soap);
	}
	soap_destroy(soap); 
	soap_end(soap);
}
Exemplo n.º 30
0
int OnvifClientPTZ::stop(std::string profileToken, bool panTilt, bool zoom){
	if (SOAP_OK != soap_wsse_add_UsernameTokenDigest(proxyPTZ.soap, NULL, _user.c_str(), _password.c_str()))
	{
		return -1;
	}

	_tptz__Stop *tptz__Stop= soap_new__tptz__Stop(soap, -1);
	_tptz__StopResponse *tptz__StopResponse = soap_new__tptz__StopResponse(soap, -1);

	tptz__Stop->ProfileToken = profileToken;
	tptz__Stop->PanTilt = &panTilt;
	tptz__Stop->Zoom = &zoom;

	if(SOAP_OK == proxyPTZ.Stop(tptz__Stop, tptz__StopResponse)){

	}else{
		//PrintErr(proxyPTZ.soap);
	}

	soap_destroy(soap); 
	soap_end(soap);
}