int main()
{
	struct _ns1__postMsgToQueue message;
	struct _ns1__postMsgToQueueResponse response;
	struct soap *soap; // gSOAP runtime environment

	message.in0 = "queue/testQueue";
	message.in1 = "teste message";

	soap = soap_new();
	if (!soap) {
		return 1;
	}

	soap_call___ns1__postMsgToQueue(soap, NULL, NULL, &message, &response);
	/*
	if (*soap.error) {
		soap_print_fault(soap, stderr);
		exit(1);
	}
	*/
	
	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Example #2
0
int main(int argc, char* argv[])
{
  ns2BikeList bl;
  struct soap *soap = soap_new();
  char search[MAX_POST_FIELD] = "";
  char type  [MAX_POST_FIELD] = "";
  uint32_t priceFrom = 0;
  uint32_t priceTo   = 0;
 
  parseArgs(argc, argv, search, MAX_POST_FIELD, type, MAX_POST_FIELD, 
            &priceFrom, &priceTo);

  if(soap_call_ns2__bikeGet(soap, NULL, NULL, search, type, priceFrom, 
                            priceTo, bl) == SOAP_OK)
  {
    logList(bl);
  }
  else
  {
    soap_print_fault(soap, stderr);
  }
  soap_end(soap);
  soap_free(soap);
  return 0;
}
Example #3
0
int ptz_ctrl_init()
{
    int i,j;
    int dev_input, option_input;
    /*创建soap通讯实体*/
    soap = soap_new();
    if(soap == NULL)
    {
        printf("soap new error\n");
        return -1;
    }

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

    /*设备列表初始化*/
    dev_list = (ov_devices_list *)calloc(1, sizeof(ov_devices_list));
    for(i = 0; i < OV_DEV_MAX_SIZE; i++)
    {
        INIT_LIST_HEAD(&(dev_list->dev[i].presets_list));
        INIT_LIST_HEAD(&(dev_list->dev[i].tours_list));
        for(j = 0; j < OV_TOURS_NUM_EACH_DEV; j++)
        {
            INIT_LIST_HEAD(&(dev_list->dev[i].tours[j].presets_list));
        }
    }
    /*寻找网络上的IPC,获取设备入口decive_addr*/
    ov_discovery_device("/root/devinfo.ini", dev_list);
    ov_show_device_list(dev_list);

}
void* NotificationConsumer::notifyFunc(void* ptr) {
    NotificationConsumer* consumer = static_cast<NotificationConsumer*>(ptr);
    int iRet;
    EventingServiceImpl* serv = new EventingServiceImpl(consumer, NULL, soap_new());

    if ( (iRet = soap_bind(serv->soap, NULL, 8080, 100) == SOAP_INVALID_SOCKET ) ) {
        SIGRLOG(SIGRCRITICAL, "NotificationConsumer::notifyFunc Binding on %d port failed", 8080);
        return NULL;
    }

    while(1) {
        bool bBreak = false;
        pthread_mutex_lock( &consumer->mutex_ );
        if(consumer->shutdownFlag_) bBreak = true;
        pthread_mutex_unlock( &consumer->mutex_ );
        if(bBreak)
            break;

        if( (iRet = soap_accept(serv->soap)) == SOAP_INVALID_SOCKET) {
            SIGRLOG(SIGRCRITICAL, "NotificationConsumer::notifyFunc accepting failed");
            return NULL;
        }

        if ( (soap_begin_serve(serv->soap)) != SOAP_OK) {
            SIGRLOG(SIGRWARNING, "NotificationConsumer::notifyFunc serve %d failed", iRet);
            continue;
        }

        if( serv )
            iRet = serv->dispatch();
        continue;
    }

    serv->destroy();
}
int getQuote (char *symbol, char *Result) {

	FlpCompDouble d;
	struct soap *soap;
	float result;
	int rc;
    char *addr = "http://services.xmethods.net/soap/";

	soap = soap_new();
	soap->namespaces = (struct Namespace *)namespaces;
	rc = soap_call_ns__getQuote(soap, addr, "", (char*)symbol, &result);
	soap_end(soap);
	free(soap);
  
	if (rc==SOAP_OK) {
		d.d= result;
		FlpFToA (d.fd,Result);
		StdEtoA(Result);
	} else {
		soap_set_fault(soap);
		strcpy (Result, soap->msgbuf);
	}
	
	return rc;

}
Example #6
0
int __cdecl main1() {

	struct soap *soap = soap_new();
	//struct_ns1__getFilesResponse response;
	struct _ns1__getFilesResponse response;
	struct _ns1__getFiles request;

		
	request.path= "/";
	
	if (soap_call___ns1__getFiles(soap,NULL,NULL,&request,&response) == SOAP_OK) {	
		printf("Current IBM Stock Quote = %d\n", response.__sizegetFilesReturn); 
		if (response.__sizegetFilesReturn > 0) {
			int i = 0;
			for (i=0; i<response.__sizegetFilesReturn; i++) {		
				if (response.getFilesReturn[i].attributes & 2)
					printf("D");
				else
					printf(" ");
				
				printf(" %s\n", response.getFilesReturn[i].name); 
			}
		}
		
	} else {
		char buffer[1024];
		soap_sprint_fault(soap,buffer,1024);
		printf("%s",buffer);
	}
		
	return 0;
}
int main(int argc, char **argv)
{ struct soap *soap;
  int m, s;
  soap = soap_new();
  if (argc < 3)
    soap_serve(soap); // run as CGI application over the Web
  else // run as stand-alone server on machine given by argv[1] listening to port argv[2]
  { m = soap_bind(soap, argv[1], atoi(argv[2]), 100);
    if (m < 0)
    { soap_print_fault(soap, stderr);
      exit(-1);
    }
    fprintf(stderr, "Socket connection successful: master socket = %d\n", m);
    for (int i = 1; ; i++)
    { s = soap_accept(soap);
      if (s < 0)
      { soap_print_fault(soap, stderr);
        exit(-1);
      }
      fprintf(stderr, "%d: accepted connection from IP = %d.%d.%d.%d socket = %d ... ", i, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF, s);
      soap_serve(soap);		// process request
      fprintf(stderr, "request served\n");
      soap_destroy(soap);	// delete class instances
      soap_end(soap);		// clean up everything and close socket
    }
  }
  return 0;
}
Example #8
0
inline void complexGsoap4()
{
	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__complexGsoap4 input, output;
	input.soap = soap;
	input.att1 = 0;
	input.att2 = 1;
	input.att3 = 2;
	input.att4 = 3;
	input.att5 = 0;
	input.att6 = 1;
	input.att7 = 2;
	input.att8 = 3;
	input.att9 = "TEST 0";
	input.att10 = "TEST 1";
	input.att11 = "TEST 2";
	input.att12 = "TEST 3";
	input.att13 = 2.5;
	input.att14 = 3.6;
	input.att15 = 4.7;
	input.att16 = 5.8;
	input.att17 = 27.1;
	input.att18 = 28.2;
	input.att19 = 29.3;
	input.att20 = 30.4;
	input.att21 = true;
	input.att22 = true;
	input.att23 = true;
	input.att24 = 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__complexGsoap4(soap, &input);
		
		//streambuf.pubseekpos(0);
		//ost->rdbuf(&streambuf);
		//std::cout << "Str: " << streambuf.size() << endl;
		//break;
		
		soap_read__ns1__complexGsoap4(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Example #9
0
//初始化soap函数
static struct soap* ONVIF_Initsoap(struct SOAP_ENV__Header *header, const char *was_To, const char *was_Action, 
		int timeout)
{
	struct soap *soap = NULL; 
	unsigned char macaddr[6];
	char _HwId[1024];
	unsigned int Flagrand;
	soap = soap_new();
	if(soap == NULL)
	{
		printf("[%d]soap = NULL\n", __LINE__);
		return NULL;
	}
	 soap_set_namespaces( soap, namespaces);
	//超过5秒钟没有数据就退出
	if (timeout > 0)
	{
		soap->recv_timeout = timeout;
		soap->send_timeout = timeout;
		soap->connect_timeout = timeout;
	}
	else
	{
		//如果外部接口没有设备默认超时时间的话,我这里给了一个默认值10s
		soap->recv_timeout    = 10;
		soap->send_timeout    = 10;
		soap->connect_timeout = 10;
	}
	soap_default_SOAP_ENV__Header(soap, header);

	// 为了保证每次搜索的时候MessageID都是不相同的!因为简单,直接取了随机值
	srand((int)time(0));
	Flagrand = rand()%9000 + 1000; //保证四位整数
	macaddr[0] = 0x1; macaddr[1] = 0x2; macaddr[2] = 0x3; macaddr[3] = 0x4; macaddr[4] = 0x5; macaddr[5] = 0x6;
	sprintf(_HwId,"urn:uuid:%ud68a-1dd2-11b2-a105-%02X%02X%02X%02X%02X%02X", 
			Flagrand, macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
	header->wsa__MessageID =(char *)malloc( 100);
	memset(header->wsa__MessageID, 0, 100);
	strncpy(header->wsa__MessageID, _HwId, strlen(_HwId));

	if (was_Action != NULL)
	{
		header->wsa__Action =(char *)malloc(1024);
		memset(header->wsa__Action, '\0', 1024);
		strncpy(header->wsa__Action, was_Action, 1024);//"http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe";
	}
	if (was_To != NULL)
	{
		header->wsa__To =(char *)malloc(1024);
		memset(header->wsa__To, '\0', 1024);
		strncpy(header->wsa__To,  was_To, 1024);//"urn:schemas-xmlsoap-org:ws:2005:04:discovery";	
	}
	soap->header = header;
	return soap;
}
Example #10
0
inline void simpleGsoap20()
{
	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__simpleGsoap20 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;
	input.att11 = 11;
	input.att12 = 12;
	input.att13 = 13;
	input.att14 = 14;
	input.att15 = 15;
	input.att16 = 16;
	input.att17 = 17;
	input.att18 = 18;
	input.att19 = 19;
	input.att20 = 20;

	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__simpleGsoap20(soap, &input);

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

		soap_read__ns1__simpleGsoap20(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Example #11
0
int main(int argc, char **argv)
{ struct soap *soap = soap_new();
  const char *endpoint;
  matrix a(soap, 3); // matrix with 3 rows created in current soap env.
  // set up matrix by specifying non-zero elements only (this is optional)
  a[1].resize(1,2); // 2-element vector indexed from 1 to 2
  a[1][1] = 2;
  a[1][2] = 1;
  a[2].resize(1,3); // 3-element vector
  a[2][1] = 1;
  a[2][2] = 2;
  a[2][3] = 1;
  a[3].resize(2,3); // 2-element vector indexed from 2 to 3
  a[3][2] = 1;
  a[3][3] = 2;
  cout << "* Demonstration example *" << endl;
  cout << "Matrix:" << endl;
  a.print();
  vector b(soap, 3);
  b[1] = 1;
  b[2] = 2;
  b[3] = 3;
  cout << "Vector:" << endl;
  b.print();
  vector x(soap);
  if (argc < 2)
    endpoint = luserver;
  else
    endpoint = argv[1];
  /* solve ax=b */
  if (soap_call_ns1__lusol(soap, endpoint, "", &a, &b, &x))
  { soap_print_fault(soap, stderr);
    soap_print_fault_location(soap, stderr);
  }
  else
  { cout << "Solution vector from service:" << endl;
    x.print();
  }
  matrix a1(soap);
  if (soap_call_ns1__luinv(soap, endpoint, "", &a, &a1))
  { soap_print_fault(soap, stderr);
    soap_print_fault_location(soap, stderr);
  }
  else
  { cout << "Inverse matrix matrix from service:" << endl;
    a1.print();
  }
  soap_destroy(soap);
  soap_end(soap);
  free(soap);
  return 0;
}
Example #12
0
Root::Root(const char *factory, enum t__object object, char *name)
{ soap = soap_new();
  endpoint = soap_strdup(soap, factory);
  status = FACTORY_NOTFOUND;
  if (name)
    if (soap_call_ns__lookup(soap, endpoint, "", object, name, status))
      soap_print_fault(soap, stderr);	// for demo, just print
  if (status == FACTORY_NOTFOUND)
    do
    { if (soap_call_ns__create(soap, endpoint, "", object, name, status))
        soap_print_fault(soap, stderr);	// for demo, just print
    } while (status == FACTORY_RETRY);
}
Example #13
0
inline void innercomplexGsoap1()
{
	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__outercomplexGsoap1 input, output;
	input.soap = soap;

	ns1__innercomplexGsoap1 inner1;
	inner1.soap = soap;
	inner1.att1 = 0;
	inner1.att2 = 0;
	inner1.att3 = "TEST 0";
	inner1.att4 = 1.5;
	inner1.att5 = 10.0;
	inner1.att6 = true;

	input.att1 = 1;
	input.att2 = 1;
	input.att3 = "TEST 1";
	input.att4 = &inner1;
	input.att5 = 10.6;
	input.att6 = 2.18;
	input.att7 = false;

	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__outercomplexGsoap1(soap, &input);

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

		soap_read__ns1__outercomplexGsoap1(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
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;
}
Example #15
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);
}
Example #16
0
void getNetworks() {
   struct soap *soap = soap_new();
   soap->userid = "u1";
   soap->passwd = "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8";
   struct ns1__getNetworksResponse networksResponse;
   if (soap_call_ns1__getNetworks(soap, NULL, NULL, "u1", &networksResponse) == SOAP_OK) {
	ArrayOf_USCORExsd_USCOREanyType* networks = networksResponse._getNetworksReturn;
	for ( int i = 0; i < networks->size; ++i ) {
		struct ns2__Network* nsNetwork = networks->_ptr[i];
		printf( "Network %d\n", nsNetwork->name );
	}	
   } else {
      soap_print_fault(soap, stderr);
   }
   soap_end(soap);
   soap_free(soap);
} 
Example #17
0
void *soap_parser_init()
{
    SoapParser *parser;

    parser = (SoapParser *)malloc(sizeof(SoapParser));
    if (NULL == parser) {
        LOGE(LOG_TAG, "out of memory");
        return NULL;
    }
    memset(parser, 0, sizeof(SoapParser));

    parser->soap = soap_new();
    if (NULL == parser->soap) {
        LOGE(LOG_TAG, "create soap failed");
        soap_parser_cleanup(parser);
        return NULL;
    }
    LOGI(LOG_TAG, "init");
    return parser;
}
Example #18
0
void *soap_parser_create()
{
    struct soap_parser *parser;

    parser = (struct soap_parser *)malloc(sizeof(struct soap_parser));
    if (NULL == parser) {
        return NULL;
    }
    memset(parser, 0, sizeof(struct soap_parser));

    snprintf(parser->tag, sizeof(parser->tag), "%s", PARSER_TAG);
    LOGI(parser->tag, "create");

    parser->soap = soap_new();
    if (NULL == parser->soap) {
        free(parser);
        return NULL;
    }

    return (void *)(parser);
}
Example #19
0
int main(int argc, char** argv)
{ 
  struct soap *soap = soap_new();
  int a, b, result;
  if(argc > 3 )
  { a = atoi(argv[1]);
    b = atoi(argv[3]);
  }
  else
      return -1;

  switch (*argv[2]) {
  case '+':
    if(soap_call_ns__add(soap, "http://localhost:8080/soap", "calculate", a, b, &result) == 0)
      printf("%d+%d=%d\n", a, b, result);
    else
      soap_print_fault(soap, stdout);
    break;
 }
  return 0;
}
Example #20
0
struct soap* CSoapUtils::newSoap(CBaseSoapSecurityInfo* securityInfo)
{
	struct soap* psoap = NULL;
	psoap = soap_new();
	if (NULL == psoap)
	{
		printf("soap new error\r\n");
		return NULL;
	}
	soap_set_namespaces(psoap, namespaces);
	psoap->recv_timeout = SOAP_RECV_TIMEOUT;
	psoap->send_timeout    = SOAP_SEND_TIMEOUT;
    psoap->connect_timeout = SOAP_CONNECT_TIMEOUT;
	struct SOAP_ENV__Header* header = static_cast<struct SOAP_ENV__Header*>(my_soap_malloc(psoap, sizeof(struct SOAP_ENV__Header)));
	
	soap_default_SOAP_ENV__Header(psoap, header);
	
	char guid_string[100] = { 0 };
	GUID guid;
	
	if (CoCreateGuid(&guid))
	{
		deleteSoap(psoap);
		printf("create guid error\r\n");
		return NULL;
	}
	
	header->wsa__MessageID = static_cast<char*>(my_soap_malloc(psoap, 100));
	strcpy(header->wsa__MessageID, guid_string);
	psoap->header = header;
	if ((NULL != securityInfo) && (securityInfo->getUserName().length() > 0)){
		std::auto_ptr<ISetSoapSecurity> ap(CFactoryImpl::getInstance().createSetSoapSecurity());
		if (!CAppTools::getInstance().isRetSuccess(ap->setSecurity(psoap, securityInfo))) {
			deleteSoap(psoap);
			printf("set security error\r\n");
			return NULL;
		}
	}
	return psoap;
}
Example #21
0
int afdmain(int argc, char **argv)
{
	struct soap *soap;
	int child_socket;

	soap = soap_new();
	soap->fget = http_get;
	if (soap_bind(soap, NULL, 8080, 100) < 0) {
		soap_print_fault(soap, stderr);
		return -1;
	}
	printf("afd started\n");
	while (1) {
		if ((child_socket = soap_accept(soap)) < 0) {
			soap_print_fault(soap, stderr);
			return -1;
		}
		soap_serve(soap);
		soap_destroy(soap);
		soap_end(soap);
	}
}
Example #22
0
int main()
{
wsHttpWellthServiceProxy service;
//char request[64];
std::string request = "*****@*****.**";
char response[64];
_ns3__GetNameByEmailID soapRequest;
_ns3__GetNameByEmailIDResponse soapResponse;
struct soap *pSoap = NULL;


pSoap = soap_new();
soap_set_namespaces(pSoap,namespaces);
soap_ssl_init();
if (soap_ssl_client_context(pSoap, SOAP_SSL_NO_AUTHENTICATION, NULL,NULL,NULL,NULL,NULL) == SOAP_OK)
  std::cout << "Client COntext set OK " << std::endl;

/**
strcpy(request,"*****@*****.**");
soapRequest.emailID = (std::string *)&request;
**/
pSoap->ssl_flags = SOAP_SSL_NO_AUTHENTICATION | SOAP_SSL_NO_DEFAULT_CA_PATH;
soapRequest.emailID = &request;
soapRequest.soap = pSoap;



// if (service.GetNameByEmailID((_ns3__GetNameByEmailID*)request,(_ns3__GetNameByEmailIDResponse*)response) == SOAP_OK)
//soap_call___ns1__GetNameByEmailID(pSoap,NULL,NULL,&soapRequest,&soapResponse);

if (service.GetNameByEmailID(&soapRequest,&soapResponse) == SOAP_OK)
  std::cout << "The response is " << response << std::endl;
else
  service.soap_stream_fault(std::cerr); 
  service.destroy(); // delete data and release memory 


}
Example #23
0
int main() {
	struct soap *mydlo = NULL;
	glite_gsplugin_Context gsplugin_ctx = NULL;
	int ok1;

	// test 1 - stdsoap2.c compatibility
	if ((mydlo = soap_new()) == NULL) {
		std::cerr << "Couldn't create soap" << std::endl;
		return 1;
	}
	soap_set_endpoint(mydlo, TEST_STR);
	std::cout << mydlo->endpoint << std::endl;
	ok1 = strcmp(mydlo->endpoint, TEST_STR);

	// test 2 - glite_gsplugin.c compatibility
	//
	// not real test, just may crash in bad test case on calling
	// soap->fdelete where will be other function
	if ( glite_gsplugin_init_context(&gsplugin_ctx) ) {
		std::cerr << "Couldn't create gSOAP plugin context" << std::endl;
		goto err;
	}
	if (soap_register_plugin_arg(mydlo, glite_gsplugin, gsplugin_ctx)) {
		std::cerr << "Couldn't register gSoap plugin" << std::endl;
		goto err;
	}

	soap_done(mydlo);
	free(mydlo);
	glite_gsplugin_free_context(gsplugin_ctx);
	return ok1;

err:
	if (gsplugin_ctx) glite_gsplugin_free_context(gsplugin_ctx);
	if (mydlo) soap_destroy(mydlo);
	return 1;
}
Example #24
0
int main(int argc, char *argv[])
{ struct soap *soap = soap_new();
  if (argc <= 1)
    return calc_serve(soap);
  else
  { float q;
    if (soap_call_ns__getQuote(soap, NULL, NULL, argv[1], &q))
      soap_print_fault(soap, stderr);
    else
    { if (argc > 2)
      { float r;
        if (soap_call_ns__getRate(soap, NULL, NULL, "us", argv[2], &r))
          soap_print_fault(soap, stderr);
        else
          q *= r;
      }
      printf("%s: %g\n", argv[1], q);
    }
  }
  soap_end(soap);
  soap_done(soap);
  free(soap);
  return 0;
}
AmazonS3SoapBindingService::AmazonS3SoapBindingService(soap_mode imode, soap_mode omode)
{	this->soap = soap_new();
	this->own = true;
	AmazonS3SoapBindingService_init(imode, omode);
}
AmazonS3SoapBindingService::AmazonS3SoapBindingService()
{	this->soap = soap_new();
	this->own = true;
	AmazonS3SoapBindingService_init(SOAP_IO_DEFAULT, SOAP_IO_DEFAULT);
}
Example #27
0
int interoptA(const char *url)
{ 
  struct soap *soap;
  int i, g;
  xsd__string so, si = "Hello World! <>&";
  struct ArrayOfstring Asi, Aso;
  xsd__int no, ni = 1234567890;
  xsd__int n = 2147483647;
  struct ArrayOfint Ani, Ano;
  xsd__float f1 = 123.5678;
  xsd__float f2 = 3.14;
  xsd__float fo, fi = 123.5;
#ifdef SYMBIAN
  const struct soap_double_nan { unsigned int n1, n2; } soap_double_nan;
#endif
  xsd__float nan = FLT_NAN, inf = FLT_PINFTY, ninf = FLT_NINFTY;
  struct ArrayOffloat Afi, Afo;
  struct s__SOAPStruct sti, *p;
  struct ns__echoStructResponse sto;
  struct ArrayOfSOAPStruct Asti, Asto;
  struct ns__echoVoidResponse Rv;
  struct xsd__base64Binary b64i, b64o;
  xsd__dateTime dto, dti = "1967-12-29T01:02:03";
  struct xsd__hexBinary hbi, hbo;
  xsd__decimal Do, Di = "1234567890.123456789";
  xsd__boolean bo, bi = true;
  displayText("running test A on");
  displayText((char*)url);
  soap = soap_new();
  soap->namespaces = (struct Namespace *)namespaces;

//  soap.send_timeout = 30;
//  soap.recv_timeout = 30;


  Asi.__size = 8;
  Asi.__offset = 0;
  Asi.__ptr = (xsd__string*)malloc(Asi.__size*sizeof(xsd__string));
  Asi.__ptr[0] = NULL;
  Asi.__ptr[1] = " Hello\tWorld";
  Asi.__ptr[2] = NULL;
  Asi.__ptr[3] = "! ";
  Asi.__ptr[4] = NULL;
  Asi.__ptr[5] = si;
  Asi.__ptr[6] = NULL;
  Asi.__ptr[7] = si;

  Ani.__size = 0;
  Ani.__offset = 0;
  Ani.__ptr = NULL; // (xsd__int*)malloc(Ani.__size*sizeof(xsd__int));

  Afi.__size = 5;
  Afi.__offset = 0;
  Afi.__ptr = (xsd__float**)malloc(Afi.__size*sizeof(xsd__float*));
  Afi.__ptr[0] = &f1;
  Afi.__ptr[1] = &f1; // FLT_NAN;
  Afi.__ptr[2] = &inf; // FLT_PINFTY;
  Afi.__ptr[3] = &ninf; // FLT_NINFTY;
  Afi.__ptr[4] = &f2;

  sti.varString = "Hello";
  sti.varInt = &n;
  sti.varFloat = &f1;

  Asti.__size = 3;
  Asti.__offset = 2;
  Asti.__ptr = (struct s__SOAPStruct**)malloc((Asti.__size+1)*sizeof(struct s__SOAPStruct*));
  p = (struct s__SOAPStruct*)malloc(Asti.__size*sizeof(struct s__SOAPStruct));
  Asti.__ptr[0] = p;
  Asti.__ptr[1] = p+1;
  Asti.__ptr[2] = p+2;
  Asti.__ptr[3] = p;
  Asti.__ptr[0]->varString = "Hello";
  Asti.__ptr[0]->varInt = &n;
  Asti.__ptr[0]->varFloat = &f1;
  Asti.__ptr[1]->varString = "World";
  Asti.__ptr[1]->varInt = &n;
  Asti.__ptr[1]->varFloat = &f2;
  Asti.__ptr[2]->varString = "!";
  Asti.__ptr[2]->varInt = &n;
  Asti.__ptr[2]->varFloat = &f2;

  unsigned char b64data[4]={0x80, 0x81, 0x82, 0x83};
  b64i.__ptr = b64data;
  b64i.__size = 4;

  hbi.__ptr = (unsigned char*)"This is an example HexBinary encoded string";
  hbi.__size = strlen((char*)hbi.__ptr)+1;
  char *site=(char*)url;
  char* action = "http://soapinterop.org/";
  
  bool ok=true;
  
  if (soap_call_ns__echoString(soap, site, action, si, so))
  { 
    displayText("echoString failed");
    ok=false;
  }
  else if (!so || strcmp(si, so))
  { 
    ok=false;
    displayText("echoString mismatch");
  }
  else
    displayText("echoString pass");
 

  if (soap_call_ns__echoInteger(soap, site, "http://soapinterop.org/", ni, no))
  { 
    ok=false;
    displayText("echoInteger fail");
  }
  else if (ni != no)
  {  
    ok=false;
    displayText("echoInteger mismatch");
  }
  else
    displayText("echoInteger pass");

  if (soap_call_ns__echoFloat(soap, site, "http://soapinterop.org/", fi, fo))
  { 
    ok=false;
    displayText("echoFloat fail");
  }
  else if (fi != fo)
  {  
    ok=false;
    displayText("echoFloat mismatch");
  }
  else
    displayText("echoFloat pass");

  if (soap_call_ns__echoStruct(soap, site, "http://soapinterop.org/", sti, sto))
  { 
    ok=false;
  displayText("echoStruct fail");
  }
  else if (!sto._return.varString || strcmp(sti.varString, sto._return.varString)
  	 || !sto._return.varInt || *sti.varInt != *sto._return.varInt 
  	 || !sto._return.varFloat || *sti.varFloat != *sto._return.varFloat)
  { 
    ok=false;
	  displayText("echoStruct mismatch");
  }
  else 
    displayText("echoStruct pass");

  if (soap_call_ns__echoStringArray(soap, site, "http://soapinterop.org/", Asi, Aso))
  {
     soap_set_fault(soap); 
    soap_faultdetail(soap);
    ok=false;
  displayText("echoStringArray fail");
  }
  else
  { g = 0;
    if (Asi.__size != Aso.__size)
      g = 1;
    else
      for (i = 0; i < Asi.__size; i++)
        if (Asi.__ptr[i] && Aso.__ptr[i] && strcmp(Asi.__ptr[i], Aso.__ptr[i]))
          g = 1;
        else if (!Asi.__ptr[i])
	  ;
        else if (Asi.__ptr[i] && !Aso.__ptr[i])
	  g = 1;
    if (g)
    {
    ok=false;
    displayText("echoStringArray mismatch"); 
    }
    else
     displayText("echoStringArray pass");
  }

  if (soap_call_ns__echoIntegerArray(soap, site, "http://soapinterop.org/", Ani, Ano))
  { displayText("echoIntegerArray fail");
    ok=false;
  }
  else
  { g = 0;
    if (Ani.__size != Ano.__size)
      g = 1;
    else
      for (i = 0; i < Ani.__size; i++)
        if (Ani.__ptr[i] && (!Ano.__ptr[i] || *Ani.__ptr[i] != *Ano.__ptr[i]))
          g = 1;
    if (g)
    { displayText("echoIntegerArray mismatch");
    ok=false;
    }
    else
      displayText("echoIntegerArray pass");
  }

  if (soap_call_ns__echoFloatArray(soap, site, "http://soapinterop.org/", Afi, Afo))
  { displayText("echoFloatArray fail");
    ok=false;
  }
  else
  { g = 0;
    if (Afi.__size != Afo.__size)
      g = 1;
    else
      for (i = 0; i < Afi.__size; i++)
        if (Afi.__ptr[i] && Afo.__ptr[i] && soap_isnan(*Afi.__ptr[i]) && soap_isnan(*Afo.__ptr[i]))
          ;
        else if (Afi.__ptr[i] && (!Afo.__ptr[i] || *Afi.__ptr[i] != *Afo.__ptr[i]))
          g = 1;
    if (g)
    { displayText("echoFloatArray mismatch");
    ok=false;
    }
    else
     displayText("echoFloatArray pass");
  }

  if (soap_call_ns__echoStructArray(soap, site, "http://soapinterop.org/", Asti, Asto))
  { displayText("echoStructArray fail");
    ok=false;
  }
  else
  { g = 0;
    if (Asti.__size+Asti.__offset != Asto.__size+Asto.__offset)
      g = 1;
    else
      for (i = Asti.__offset; i < Asti.__size+Asti.__offset; i++)
        if (!Asto.__ptr[i-Asto.__offset] ||
	!Asto.__ptr[i-Asto.__offset]->varString ||
	strcmp(Asti.__ptr[i-Asti.__offset]->varString, Asto.__ptr[i-Asto.__offset]->varString) ||
	!Asto.__ptr[i-Asto.__offset]->varInt ||
	*Asti.__ptr[i-Asti.__offset]->varInt != *Asto.__ptr[i-Asto.__offset]->varInt ||
	!Asto.__ptr[i-Asto.__offset]->varFloat ||
	*Asti.__ptr[i-Asti.__offset]->varFloat != *Asto.__ptr[i-Asto.__offset]->varFloat)
          g = 1;
    if (g)
    { displayText("echoStructArray mismatch");
    ok=false;
    }
    else
      displayText("echoStructArray pass");
  }

  if (soap_call_ns__echoVoid(soap, site, "http://soapinterop.org/", Rv))
  { displayText("echoVoid fail");
    ok=false;
  }
  else
    displayText("echoVoid pass");
  
  {
    int S1=sizeof(int);
    int S2= sizeof (size_t);
    int S3=sizeof(0);
    }

  if (soap_call_ns__echoBase64(soap, site, "http://soapinterop.org/", b64i, b64o))
  { displayText("echoBase64 fail");
    ok=false;
  }
  else if ((b64i.__size+2)/3 != (b64o.__size+2)/3 || strncmp((char*)b64i.__ptr, (char*)b64o.__ptr,b64i.__size))
  { 
  displayText("echoBase64 mismatch");
    ok=false;
  }
  else
   displayText("echoBase64 pass");

  if (soap_call_ns__echoDate(soap, site, "http://soapinterop.org/", dti, dto))
  { 
  displayText("echoDate fail");
    ok=false;
  }
  else if (!dto || strncmp(dti, dto, 19))
  { 
  displayText("echoDate mismatch");
    ok=false;
  }
  else
    displayText("echoDate pass");
 

  if (soap_call_ns__echoHexBinary(soap, site, "http://soapinterop.org/", hbi, hbo))
  { 
    ok=false;
  displayText("echoHexBinary fail");
  }
  else if (hbi.__size != hbo.__size || strcmp((char*)hbi.__ptr, (char*)hbo.__ptr))
  { 
    ok=false;
  displayText("echoHexBinary mismatch");
  }
  else
    displayText("echoHexBinary pass");
 

  if (soap_call_ns__echoDecimal(soap, site, "http://soapinterop.org/", Di, Do))
  { 
    ok=false;
  displayText("echoDecimal pass");
  }
  else if (strcmp(Di, Do))
  { 
    ok=false;
  displayText("echoDecimal mismatch");
  }
  else
    displayText("echoDecimal pass");
  

  if (soap_call_ns__echoBoolean(soap, site, "http://soapinterop.org/", bi, bo))
  { 
    ok=false;
    displayText("echoBoolean fail");
  }
  else if (bi != bo)
  { 
    ok=false;
    displayText("echoBoolean mismatch");
  }
  else
    displayText("echoBoolean pass");

  soap_end(soap);
  soap_done(soap);
  if (ok)
  	displayText("ALL PASS");
  else
	displayText("FAILURES");
  return 0;
  
end:
  return 1;
}
Example #28
0
int main(int argc, char *argv[]) {
    /* 变量声明 */
    struct soap *soap;  //soap环境变量      
    struct wsdd__ProbeType req;   //用于发送消息描述   
    struct wsdd__ProbeType wsdd__Probe;
    struct __wsdd__ProbeMatches resp;
    //struct wsdd__ProbeMatchesType resp; //请求消息的回应
    struct wsdd__ScopesType sScope; //描述查找哪类的Web服务
    struct SOAP_ENV__Header header; //soap消息头描述
    int count = 0;  //获得的设信息备个数
    int result = 0;    //返回值        
	unsigned char macaddr[6];  
	char _HwId[1024];  
	unsigned int Flagrand;

	// Create SessionID randomly  
	srand((int)time(0));  
	Flagrand = rand()%9000 + 8888;   
	macaddr[0] = 0x1;
	macaddr[1] = 0x2; 
	macaddr[2] = 0x3; 
	macaddr[3] = 0x4; 
	macaddr[4] = 0x5; 
	macaddr[5] = 0x6;  
	sprintf(_HwId,"urn:uuid:%ud68a-1dd2-11b2-a105-%02X%02X%02X%02X%02X%02X", Flagrand, macaddr[0], macaddr[1], macaddr[2], macaddr[3], macaddr[4], macaddr[5]);
    /************初始化*************/
    soap = soap_new(); //为soap申请变量空间,并初始化
    if ( soap == NULL) {
		return -1;
	}
    soap_set_namespaces(soap, namespaces); //设置soap的namespaces
    soap->recv_timeout = 5; //超过5秒钟没有数据就退出
    soap_default_SOAP_ENV__Header(soap, &header);//将header设置为soap消息    头属性
    header.wsa__MessageID = _HwId;
    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头消息的ID
    //设置soap消息的请求服务属性
    soap_default_wsdd__ScopesType(soap, &sScope);
    sScope.__item = "";     
	//sScope.__item = "onvif://www.onvif.org";
    soap_default_wsdd__ProbeType(soap, &req);
    req.Scopes = &sScope;
    //req.Types = "tdn:NetworkVideoTransmitter";
    req.Types = "tds:Device";
    //调用gSoap接口
    //soap_wsdd_Probe
    result  = soap_send___wsdd__Probe(soap, "soap.udp://239.255.255.250:3702", NULL, &req);
    printf("%s: %d, send probe request success!\n",__FUNCTION__, __LINE__);
    if ( result == -1 ) {
        printf ( "soap error: %d, %s, %s\n", soap->error, *soap_faultcode(soap), *soap_faultstring(soap));
        result = soap->error;
    } else {
        do {
            printf("%s: %d, begin receive probematch... \n",__FUNCTION__, __LINE__);
            printf("count=%d \n",count);
            //接收ProbeMatches,成功返回0,否则-1
            result = soap_recv___wsdd__ProbeMatches(soap, &resp);
            printf(" --soap_recv___wsdd__ProbeMatches() result=%d \n",result);
            if (result==-1) {
                printf("Find %d devices!\n", count);
                break;
            } else {                     
                //读取服务端回应的Probematch消息
				if ( resp.wsdd__ProbeMatches){
					/***
					printf("soap_recv___wsdd__Probe:  __sizeProbeMatch=%d\r\n",resp.wsdd__ProbeMatches->__sizeProbeMatch);
					printf("Target EP Address : %s\r\n",      resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address);
					printf("Target Type : %s\r\n",            resp.wsdd__ProbeMatches->ProbeMatch->Types);
					printf("Target Service Address : %s\r\n", resp.wsdd__ProbeMatches->ProbeMatch->XAddrs);
					printf("Target Metadata Version : %d\r\n",resp.wsdd__ProbeMatches->ProbeMatch->MetadataVersion);
					printf("Target Scopes Address : %s\r\n",  resp.wsdd__ProbeMatches->ProbeMatch->Scopes->__item);
					**/
					DeviceInfo device;
					device.dev_uuid = resp.wsdd__ProbeMatches->ProbeMatch->wsa__EndpointReference.Address;
					device.dev_server_address =  resp.wsdd__ProbeMatches->ProbeMatch->XAddrs;
					char duplicate = 0;
					int index = 0;
					while ( index < MAX_DEVICE) {
						char *uuid = g_device_list[ index].dev_uuid;
						if ( uuid != NULL && strcmp( uuid, device.dev_uuid) == 0 ) {
							duplicate = 1;
							break;
						}
						++index;
					}
					if ( duplicate == 0) {
						printf ( " find device no :%d  \n" , ( count +1));
						printf ( " uuid : %s  \n" , device.dev_uuid);
						printf ( " server address : %s  \n" , device.dev_server_address);
						g_device_list[ count] = device;
						count += 1;
					}
				}
            }
        } while ( 1);
    }
    //清除soap
    soap_end(soap); // clean up and remove deserialized data
    soap_free(soap);//detach and free runtime context
    soap_done(soap); // detach context (last use and no longer in scope)
    return result;
}
Example #29
0
int main(int argc, char* argv[])
{		
	std::string indevice  = "/dev/video0";
	std::string inpath    = "unicast";
	std::string outdevice = "/dev/video10";
	std::string outpath   = "rtsp://127.0.0.1:8554/unicast";
	std::string username;
	std::string password;	
	int port = 8080;
	int c = 0;
	while ((c = getopt (argc, argv, "h" "u:p:" "P:" "i:I:o:O:")) != -1)
	{
		switch (c)
		{
			case 'P':	port      = atoi(optarg); break;

			case 'u':	username  = optarg; break;
			case 'p':	password  = optarg; break;
			
			case 'i':	indevice  = optarg; break;
			case 'I':	inpath    = optarg; break;
			
			case 'o':	outdevice = optarg; break;
			case 'O':	outpath   = optarg; break;
			
			case 'h':
				std::cout << argv[0] << " [-u username] [-p password] [-i v4l2 input device] [-I rtsp server] [-o v4l2 output device] [-O rtsp client]" << std::endl;
				exit(0);
			break;
		}
	}
	std::cout << "Listening to " << port << std::endl;
		
	ServiceContext deviceCtx;
	deviceCtx.m_devices.insert(std::pair<std::string,std::string>(indevice, inpath));
	deviceCtx.m_port          = port;
	deviceCtx.m_user          = username;
	deviceCtx.m_password      = password;
	deviceCtx.m_outdevice     = outdevice;
	deviceCtx.Manufacturer    = "Manufacturer";
	deviceCtx.Model           = "Model";
	deviceCtx.FirmwareVersion = "FirmwareVersion";
	deviceCtx.SerialNumber    = "SerialNumber";
	deviceCtx.HardwareId      = "HardwareId";
	deviceCtx.m_scope.push_back("onvif://www.onvif.org/name/Name");
	deviceCtx.m_scope.push_back("onvif://www.onvif.org/location/Here");
	deviceCtx.m_scope.push_back("onvif://www.onvif.org/Profile/Streaming");
	deviceCtx.m_scope.push_back("onvif://www.onvif.org/Profile/G");
	
	struct soap *soap = soap_new();
	soap->user = (void*)&deviceCtx;
	soap->fget = http_get; 
	{			
		FOREACH_SERVICE(DECLARE_SERVICE,soap)

		if (!soap_valid_socket(soap_bind(soap, NULL, deviceCtx.m_port, 100))) 
		{
			soap_stream_fault(soap, std::cerr);
		}
		else
		{
			while (soap_accept(soap) != SOAP_OK) 
			{
				if (soap_begin_serve(soap))
				{
					soap_stream_fault(soap, std::cerr);
				}
				FOREACH_SERVICE(DISPATCH_SERVICE,soap)
				else 
				{
					std::cout << "Unknown service" << std::endl;				
				}
					
			}
		}
	}
	
	soap_destroy(soap);
	soap_end(soap);
	soap_free(soap); 			
	
	return 0;
}
    soap_serialize_xsd__anyType(e.soap, &e);
    soap_begin_send(e.soap);
    e.soap->ns = 2; /* do not dump namespace table */
    soap_out_xsd__anyType(e.soap, NULL, 0, &e, NULL);
    soap_end_send(e.soap);
    e.soap->os = os;
    e.soap->omode = omode;
  }
  return o;
}

/******************************************************************************/

std::istream &operator>>(std::istream &i, struct soap_dom_element &e)
{ if (!e.soap)
    e.soap = soap_new();
  std::istream *is = e.soap->is;
  e.soap->is = &i;
  if (soap_begin_recv(e.soap)
   || !soap_in_xsd__anyType(e.soap, NULL, &e, NULL)
   || soap_end_recv(e.soap))
  { /* handle error? Note: e.soap->error is set and app should check */
  }
  e.soap->is = is;
  return i;
}

#endif

#endif