Example #1
0
int run_tests(int argc, char **argv)
{
  struct soap *soap = soap_new1(SOAP_XML_INDENT);
  struct ns__echoString r;
  char *endpoint, *arg;
  int ret;

  soap_register_plugin(soap, http_da);

  endpoint = argv[1];
  arg = argv[2];

  if (strchr(arg, 'c'))
    soap_set_omode(soap, SOAP_IO_CHUNK);

  if (strchr(arg, 'z'))
    soap_set_omode(soap, SOAP_ENC_ZLIB);

  if (soap_call_ns__echoString(soap, endpoint, NULL, arg, &r))
  {
    if (soap->error == 401)
    {
      if (!strcmp(soap->authrealm, authrealm))
      {
	/* save userid and passwd for basic or digest authentication */
	struct http_da_info info;
	http_da_save(soap, &info, authrealm, "Mufasa", "Circle Of Life");
        if (!soap_call_ns__echoString(soap, endpoint, NULL, arg, &r))
	{
	  soap_end(soap);
	  /* need to restore for authentication */
	  http_da_restore(soap, &info);
	  if (!soap_call_ns__echoString(soap, endpoint, NULL, arg, &r))
          {
	    if (!strcmp(arg, r.arg))
              printf("EchoString test OK\n");
            else
              printf("Transmission error\n");
	  } 
        }
	http_da_release(soap, &info);
	/* regular calls may follow */
      }
    }
  }
  if (soap->error)
    soap_print_fault(soap, stderr);
  ret = soap->error;
  soap_destroy(soap);
  soap_end(soap);
  soap_free(soap);
  return ret;
}
void WSMessageStreamImporter::run()
{
	unsigned int ulResult = 0;
	xsd__Binary	sStreamData = {{0}};

	struct soap *lpSoap = m_ptrTransport->m_lpCmd->soap;
	propVal *lpsConflictItems = NULL;

	if (m_sConflictItems.ulPropTag != 0)
		lpsConflictItems = &m_sConflictItems;

	sStreamData.xop__Include.__ptr = (unsigned char*)this;
	sStreamData.xop__Include.type = "application/binary";

	m_ptrTransport->LockSoap();

	soap_set_omode(lpSoap, SOAP_ENC_MTOM | SOAP_IO_CHUNK);	
    lpSoap->mode &= ~SOAP_XML_TREE;
    lpSoap->omode &= ~SOAP_XML_TREE;
	lpSoap->fmimereadopen = &StaticMTOMReadOpen;
	lpSoap->fmimeread = &StaticMTOMRead;
	lpSoap->fmimereadclose = &StaticMTOMReadClose;

	m_hr = hrSuccess;
	if (m_ptrTransport->m_lpCmd->ns__importMessageFromStream(m_ptrTransport->m_ecSessionId, m_ulFlags, m_ulSyncId, m_sFolderEntryId, m_sEntryId, m_bNewMessage, lpsConflictItems, sStreamData, &ulResult) != SOAP_OK) {
		m_hr = MAPI_E_NETWORK_ERROR;
	} else if (m_hr == hrSuccess) {	// Could be set from callback
		m_hr = ZarafaErrorToMAPIError(ulResult, MAPI_E_NOT_FOUND);
	}

	m_ptrTransport->UnLockSoap();
}
/**
 * Initializes this task database
 *
 * @return	true if successful
 */
bool FTestTrackProvider::Init()
{
	TDLOG( TEXT( "TestTrack: Initializing TestTrack provider" ) );


	// Allocate SOAP interface to TestTrack Pro
	TestTrackSoap = new ttsoapcgi();
	check( TestTrackSoap != NULL );


	// @todo: Are there any other SOAP options we want to be configuring here?


	// Disable multi-referenced strings (href="#_12").  This makes the XML structures larger but
	// TestTrack doesn't support resolving graph references.  This effectively changes the graph
	// to a tree with duplicated strings where needed.
	soap_clr_omode( TestTrackSoap->soap, SOAP_XML_GRAPH );
	soap_set_omode( TestTrackSoap->soap, SOAP_XML_TREE );


	// Set timeouts for SOAP network I/O
	TestTrackSoap->soap->recv_timeout = 10000;		/* when > 0, gives socket recv timeout in seconds, < 0 in usec */
	TestTrackSoap->soap->send_timeout = 4000;		/* when > 0, gives socket send timeout in seconds, < 0 in usec */
	TestTrackSoap->soap->connect_timeout = 4000;	/* when > 0, gives socket connect() timeout in seconds, < 0 in usec */
	TestTrackSoap->soap->accept_timeout = 4000;		/* when > 0, gives socket accept() timeout in seconds, < 0 in usec */


	TDLOG( TEXT( "TestTrack: TestTrack provider finished initializing" ) );

	return true;
}
Example #4
0
void TCSoapThread(const std::string& host, uint16 port)
{
    struct soap soap;
    soap_init(&soap);
    soap_set_imode(&soap, SOAP_C_UTFSTRING);
    soap_set_omode(&soap, SOAP_C_UTFSTRING);

    // check every 3 seconds if world ended
    soap.accept_timeout = 3;
    soap.recv_timeout = 5;
    soap.send_timeout = 5;
    if (!soap_valid_socket(soap_bind(&soap, host.c_str(), port, 100)))
    {
        TC_LOG_ERROR("network.soap", "Couldn't bind to %s:%d", host.c_str(), port);
        exit(-1);
    }

    TC_LOG_INFO("network.soap", "Bound to http://%s:%d", host.c_str(), port);

    while (!World::IsStopped())
    {
        if (!soap_valid_socket(soap_accept(&soap)))
            continue;   // ran into an accept timeout

        TC_LOG_DEBUG("network.soap", "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
        struct soap* thread_soap = soap_copy(&soap);// make a safe copy
        process_message(thread_soap);
    }

    soap_done(&soap);
}
int open_data(struct soap *soap, const char *file, struct x__Data *data)
{ struct stat sb;
  FILE *fd = NULL;
  int size;
  soap_default_x__Data(soap, data);
  fd = fopen(file, "rb");
  if (!fd)
  { fprintf(stderr, "Cannot open file %s\n", file);
    return soap->error = SOAP_EOF;
  }
  /* The handle for the streaming MIME callback is the open file fd */      
  data->xop__Include.__ptr = (unsigned char*)fd;
  if (!fstat(fileno(fd), &sb) && sb.st_size > 0)
    size = sb.st_size;
  else
  { /* File size is unknown, so must use HTTP chunking and set size = 0 */
    soap_set_omode(soap, SOAP_IO_CHUNK);
    size = 0;
  }
  data->xop__Include.__size = size;
  data->xmime4__contentType = file_type(file);
  data->xop__Include.id = NULL;
  data->xop__Include.type = data->xmime4__contentType;
  data->xop__Include.options = NULL;
  return SOAP_OK;
}
Example #6
0
std::ostream &operator<<(std::ostream &o, const struct soap_dom_element &e)
{ if (!e.soap)
  { struct soap soap;
    soap_init2(&soap, SOAP_IO_DEFAULT, SOAP_XML_GRAPH);
    soap_mark_xsd__anyType(&soap, &e);
    soap_begin_send(&soap);
    soap_put_xsd__anyType(&soap, &e, NULL, NULL);
    soap_end_send(&soap);
    soap_end(&soap);
    soap_done(&soap);
  }
  else
  { std::ostream *os = e.soap->os;
    e.soap->os = &o;
    short omode = e.soap->omode;
    soap_set_omode(e.soap, SOAP_XML_GRAPH);
    soap_mark_xsd__anyType(e.soap, &e);
    soap_begin_send(e.soap);
    soap_put_xsd__anyType(e.soap, &e, NULL, NULL);
    soap_end_send(e.soap);
    e.soap->os = os;
    e.soap->omode = omode;
  }
  return o;
}
Example #7
0
void TCSoapRunnable::run()
{
    struct soap soap;
    soap_init(&soap);
    soap_set_imode(&soap, SOAP_C_UTFSTRING);
    soap_set_omode(&soap, SOAP_C_UTFSTRING);

    // check every 3 seconds if world ended
    soap.accept_timeout = 3;
    soap.recv_timeout = 5;
    soap.send_timeout = 5;
    if (!soap_valid_socket(soap_bind(&soap, _host.c_str(), _port, 100)))
    {
        TC_LOG_ERROR("network.soap", "Couldn't bind to %s:%d", _host.c_str(), _port);
        exit(-1);
    }

    TC_LOG_INFO("network.soap", "Bound to http://%s:%d", _host.c_str(), _port);

    while (!World::IsStopped())
    {
        if (!soap_valid_socket(soap_accept(&soap)))
            continue;   // ran into an accept timeout

        TC_LOG_DEBUG("network.soap", "Accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip>>24)&0xFF, (int)(soap.ip>>16)&0xFF, (int)(soap.ip>>8)&0xFF, (int)soap.ip&0xFF);
        struct soap* thread_soap = soap_copy(&soap);// make a safe copy

        ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*));
        ACE_OS::memcpy(mb->wr_ptr(), &thread_soap, sizeof(struct soap*));
        process_message(mb);
    }

    soap_done(&soap);
}
std::ostream &operator<<(std::ostream &o, const struct soap_dom_element &e)
{ if (!e.soap)
  { struct soap soap;
    soap_init2(&soap, SOAP_IO_DEFAULT, SOAP_XML_GRAPH);
    soap_serialize_xsd__anyType(&soap, &e);
    soap_begin_send(&soap);
    soap.ns = 2; /* do not dump namespace table */
    soap_out_xsd__anyType(&soap, NULL, 0, &e, NULL);
    soap_end_send(&soap);
    soap_end(&soap);
    soap_done(&soap);
  }
  else
  { std::ostream *os = e.soap->os;
    e.soap->os = &o;
    soap_mode omode = e.soap->omode;
    soap_set_omode(e.soap, SOAP_XML_GRAPH);
    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;
}
Example #9
0
File: event.c Project: 119-org/TND
int main()
{ struct soap soap;
  soap_init2(&soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE | SOAP_XML_INDENT);
  /* Events A to C do not generate a response from the server */
  fprintf(stderr, "Client Sends Event: A\n");
  if (soap_send_ns__handle(&soap, event_handler_endpoint, event_handler_action, EVENT_A))
    soap_print_fault(&soap, stderr);
  if (synchronous && soap_recv_empty_response(&soap))
    soap_print_fault(&soap, stderr);
  fprintf(stderr, "Client Sends Event: B\n");
  if (soap_send_ns__handle(&soap, event_handler_endpoint, event_handler_action, EVENT_B))
    soap_print_fault(&soap, stderr);
  if (synchronous && soap_recv_empty_response(&soap))
    soap_print_fault(&soap, stderr);
  /* reset keep-alive when client needs to inform the server that it will close the connection. It may reconnect later */
  soap_clr_omode(&soap, SOAP_IO_KEEPALIVE);
  fprintf(stderr, "Client Sends Event: C\n");
  if (soap_send_ns__handle(&soap, event_handler_endpoint, event_handler_action, EVENT_C))
    soap_print_fault(&soap, stderr);
  if (synchronous && soap_recv_empty_response(&soap))
    soap_print_fault(&soap, stderr);
  /* close the socket */
  soap_closesock(&soap);
  /* re-enable keep-alive which is required to accept and execute multiple receives */
  soap_set_omode(&soap, SOAP_IO_KEEPALIVE);
  /* Events Z generates a series of response from the server */
  fprintf(stderr, "Client Sends Event: Z\n");
  if (soap_send_ns__handle(&soap, event_handler_endpoint, event_handler_action, EVENT_Z))
    soap_print_fault(&soap, stderr);
  else
  { struct ns__handle response;
    for (;;)
    { if (!soap_valid_socket(soap.socket))
      { fprintf(stderr, "Connection was terminated (keep alive disabled?)\n");
        break;
      }
      if (soap_recv_ns__handle(&soap, &response))
      { if (soap.error == SOAP_EOF)
          fprintf(stderr, "Connection was gracefully closed by server\n");
        else
	  soap_print_fault(&soap, stderr);
	break;
      }
      else
      { switch (response.event)
        { case EVENT_A: fprintf(stderr, "Client Received Event: A\n"); break;
          case EVENT_B: fprintf(stderr, "Client Received Event: B\n"); break;
          case EVENT_C: fprintf(stderr, "Client Received Event: C\n"); break;
          case EVENT_Z: fprintf(stderr, "Client Received Event: Z\n"); break;
        }
      }
    }
  }
  soap_closesock(&soap); /* soap_send operations keep the socket open to possibly accept responses, so we need to explicitly close the socket now */
  soap_end(&soap); /* this will close the socket too (if keep alive is off), just in case */
  soap_done(&soap); /* detach environment (also closes sockets even with keep-alive) */
  return 0;
}
Example #10
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 #11
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 #12
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);
}
Example #13
0
void MaNGOSsoapRunnable::run()
{
    // Create pool
    SOAPWorkingThread pool;
    pool.activate(THR_NEW_LWP | THR_JOINABLE, POOL_SIZE);

    struct soap soap;
    int m, s;
    soap_init(&soap);
    soap_set_imode(&soap, SOAP_C_UTFSTRING);
    soap_set_omode(&soap, SOAP_C_UTFSTRING);
    m = soap_bind(&soap, m_host.c_str(), m_port, 100);

    // Check every 3 seconds if world ended
    soap.accept_timeout = 3;

    soap.recv_timeout = 5;
    soap.send_timeout = 5;
    if (m < 0)
    {
        sLog.outError("MaNGOSsoap: couldn't bind to %s:%d", m_host.c_str(), m_port);
        exit(-1);
    }

    sLog.outString("MaNGOSsoap: bound to http://%s:%d", m_host.c_str(), m_port);

    while (!World::IsStopped())
    {
        s = soap_accept(&soap);

        if (s < 0)
        {
            // Ran into an accept timeout
            continue;
        }

        DEBUG_LOG("MaNGOSsoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);
        // Make a safe copy
        struct soap* thread_soap = soap_copy(&soap);

        ACE_Message_Block* mb = new ACE_Message_Block(sizeof(struct soap*));
        ACE_OS::memcpy(mb->wr_ptr(), &thread_soap, sizeof(struct soap*));
        pool.putq(mb);
    }

    pool.msg_queue()->deactivate();
    pool.wait();

    soap_done(&soap);
}
Example #14
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 #15
0
int main(int argc, char **argv)
{ char *buf;
  size_t len;
  struct soap soap;

  soap_init(&soap);
  /* chunking conserves memory and is generally faster: */
  soap_set_omode(&soap, SOAP_IO_CHUNK);

  if (argc < 2)
  { /* CGI server */
    struct http_post_handlers handlers[] =
    { { "image/jpg", jpg_handler },
      { "image/*",   image_handler },
      { "image/*;*", image_handler },
      { "text/*",    text_handler },
      { "text/*;*",  text_handler },
      { NULL }
    };
    soap_register_plugin_arg(&soap, http_post, handlers); /* register plugin (server only) */
    soap_serve(&soap);
    exit(0);
  }

  /* client */
  if (soap_post_connect(&soap, argv[1], NULL, "text/html")
   || soap_send(&soap, "<html>")
   || soap_send(&soap, argc == 2 ? "Hello" : argv[2])
   || soap_send(&soap, "</html>")
   || soap_end_send(&soap))
  { soap_print_fault(&soap, stderr);
    exit(1);
  }
  /* after sending, receive body (note: POST handlers should not be set) */
  if (soap_begin_recv(&soap)
   || soap_http_body(&soap, &buf, &len)
   || soap_end_recv(&soap))
  { soap_print_fault(&soap, stderr);
    exit(1);
  }
  printf("Received %lu bytes of type %s:\n", (unsigned long)len, soap.http_content?soap.http_content:"");
  soap_end(&soap);
  soap_done(&soap);
  return 0;
}
Example #16
0
void SOAPThread::Work()
{
    soap soap;

    soap_init(&soap);
    soap_set_imode(&soap, SOAP_C_UTFSTRING);
    soap_set_omode(&soap, SOAP_C_UTFSTRING);

    soap.accept_timeout = AcceptTimeout;
    soap.recv_timeout = DataTimeout;
    soap.send_timeout = DataTimeout;

    if (soap_bind(&soap, m_host.c_str(), m_port, BackLogSize) < 0)
    {
        sLog.outError("MaNGOSsoap: couldn't bind to %s:%d", m_host.c_str(), m_port);
        exit(-1);
    }

    sLog.outString("MaNGOSsoap: bound to http://%s:%d", m_host.c_str(), m_port);

    while (!World::IsStopped())
    {
        auto s = soap_accept(&soap);

        // timeout?
        if (s == SOAP_INVALID_SOCKET)
            continue;

        DEBUG_LOG("MaNGOSsoap: accepted connection from IP=%d.%d.%d.%d", (int)(soap.ip >> 24) & 0xFF, (int)(soap.ip >> 16) & 0xFF, (int)(soap.ip >> 8) & 0xFF, (int)soap.ip & 0xFF);

        auto copy = soap_copy(&soap);
        soap_serve(copy);
        soap_destroy(copy);
    }

    soap_end(&soap);
    soap_done(&soap);
}
Example #17
0
inline void simpleGsoap50()
{
	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__simpleGsoap50 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;
	input.att21 = 21;
	input.att22 = 22;
	input.att23 = 23;
	input.att24 = 24;
	input.att25 = 25;
	input.att26 = 26;
	input.att27 = 27;
	input.att28 = 28;
	input.att29 = 29;
	input.att30 = 30;
	input.att31 = 31;
	input.att32 = 32;
	input.att33 = 33;
	input.att34 = 34;
	input.att35 = 35;
	input.att36 = 36;
	input.att37 = 37;
	input.att38 = 38;
	input.att39 = 39;
	input.att40 = 40;
	input.att41 = 41;
	input.att42 = 42;
	input.att43 = 43;
	input.att44 = 44;
	input.att45 = 45;
	input.att46 = 46;
	input.att47 = 47;
	input.att48 = 48;
	input.att49 = 49;
	input.att50 = 50;

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

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

		soap_read__ns1__simpleGsoap50(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Example #18
0
int main()
{
  struct soap *ctx = soap_new1(SOAP_XML_INDENT);

  soap_set_namespaces(ctx, nosoap_nsmap);

  // a tree:
  Graph tree;
  // with 5 branches:
  for (int i = 0; i < 4; ++i)
  {
    Graph *branch = soap_new_Graph(ctx);
    tree.edges.push_back(branch);
    // each branch has a couple of leaves:
    for (int j = 0; j < i; ++j)
      branch->edges.push_back(soap_new_Graph(ctx));
  }

  std::cout << "**** XML TREE FROM C++ TREE ****" << std::endl;
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;

  std::cout << "**** XML TREE FROM C++ DIGRAPH ****" << std::endl;
  tree.edges[0] = tree.edges[1]; // first pair of edges point to shared node
  tree.edges[2] = tree.edges[3]; // second pair of edges point to shared node
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;

  std::cout << "**** XML ID-REF DIGRAPH FROM C++ DIGRAPH ****" << std::endl;
  soap_set_omode(ctx, SOAP_XML_GRAPH);
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;
  soap_clr_omode(ctx, SOAP_XML_GRAPH);

  std::cout << "**** XML ID-REF DIGRAPH FROM C++ CYCLIC GRAPH ****" << std::endl;
  tree.edges[0]->edges = tree.edges;   // create cycle
  soap_set_omode(ctx, SOAP_XML_GRAPH);
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;
  soap_clr_omode(ctx, SOAP_XML_GRAPH);

  std::cout << "**** XML TREE (PRUNED CYCLIC BRANCHES) FROM C++ CYCLIC GRAPH ****" << std::endl;
  soap_set_omode(ctx, SOAP_XML_TREE);
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;
  soap_clr_omode(ctx, SOAP_XML_TREE);

  std::cout << "**** SOAP 1.1 ENCODED GRAPH FROM C++ CYCLIC GRAPH ****" << std::endl;
  soap_set_namespaces(ctx, soap11_nsmap);
  soap_set_version(ctx, 1);        // enable SOAP 1.1
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;

  std::cout << "**** SOAP 1.2 ENCODED GRAPH FROM C++ CYCLIC GRAPH ****" << std::endl;
  soap_set_namespaces(ctx, soap12_nsmap);
  soap_set_version(ctx, 2);        // enable SOAP 1.2
  soap_write_Graph(ctx, &tree);
  std::cout << std::endl << std::endl;

  soap_destroy(ctx); // delete objects
  soap_end(ctx);     // free temp data
  soap_free(ctx);    // release context

  return 0;
}
Example #19
0
messages_t* getMessages(struct soap* soap, char* date) {
   struct _ns1__messageResponseTypeDef* msgs = getMessage(soap, new_reqList(soap, "getMessageAll", "sent", "greaterthan", date));

   if (msgs) {
     int old_fd = soap->sendfd;
     messages_t* msg_t = NULL;

     msg_t = (messages_t*) malloc(sizeof(messages_t));
     if (!msg_t) {
       perror("Error converting alerts to text. Out of memory [0]");
       return NULL;
     }

     msg_t->size = msgs->__sizealert;
     msg_t->alerts = (char**) malloc(sizeof(char*)*(msg_t->size));
     if (!msg_t->alerts) {
       perror("Error converting alerts to text. Out of memory [1]");
       free(msg_t);
       return NULL;
     } 

     msg_t->ids = (char**) malloc(sizeof(char*)*(msg_t->size));
     if (!msg_t->ids) {
       perror("Error converting alerts to text. Out of memory [2]");
       free(msg_t->alerts);
       free(msg_t);
       return NULL;
     }

     msg_t->expires = (time_t**) malloc(sizeof(time_t*)*(msg_t->size));
     if (!msg_t->ids) {
       perror("Error converting alerts to text. Out of memory [3]");
       free(msg_t->ids);
       free(msg_t->alerts);
       free(msg_t);
       return NULL;
     }

     for (unsigned int i = 0; i < msg_t->size; i++) {
       msg_t->alerts[i] = NULL;
       msg_t->ids[i] = NULL;
       msg_t->expires[i] = NULL;
     }

     for (int i = 0; i < msgs->__sizealert; i++) {
       FILE* tmpf = tmpfile();
       struct stat stbuf;

       soap->sendfd = fileno(tmpf);
       soap_set_omode(soap, SOAP_ENC_XML);
       soap_begin_send(soap);
       soap_serialize__ns4__alert(soap, &(msgs->ns4__alert[i]));
       soap_put__ns4__alert(soap, &(msgs->ns4__alert[i]), NULL, NULL);
       soap_end_send(soap);
       soap_clr_omode(soap, SOAP_ENC_XML);
       soap->sendfd = old_fd;

       if ( fstat(fileno(tmpf), &stbuf) == -1 ) {
	 perror("Encountered error converting alert to text");
	 goto error_inconsistent_msg_t;
       }

       msg_t->alerts[i] = (char*) malloc(stbuf.st_size+1);
       if (msg_t->alerts[i]) {
	 rewind(tmpf);
	 if (fread(msg_t->alerts[i], stbuf.st_size, 1, tmpf) < 1) {
	   perror("Incomplete conversion of alert to text. Discarding");
	   free(msg_t->alerts[i]);
	   goto error_inconsistent_msg_t;
	 }
	 msg_t->alerts[i][stbuf.st_size] = '\0';
	 fclose(tmpf);

	 msg_t->ids[i] = strdup(msgs->ns4__alert[i].identifier);
	 if (!msg_t->ids[i]) {
	   perror("Incomplete conversion of alert to text, discarding");
	   free(msg_t->alerts[i]);
	   goto error_inconsistent_msg_t;
	 }

	 // Get the latest expiration date
	 for(int j = 0; j < msgs->ns4__alert[i].__sizeinfo; j++) {
	   if (msg_t->expires[i] == NULL) { // Don't alloc more than once
	     msg_t->expires[i] = malloc(sizeof(time_t));
	     if (msg_t->expires[i]) {
	       if (msgs->ns4__alert[i].info) {
		 if (msgs->ns4__alert[i].info[j].expires) {
		   *(msg_t->expires[i]) = *(msgs->ns4__alert[i].info[j].expires);
		 } else {
		   error(0, 0, "Allocated info doesn't have expires field");
		   free(msg_t->expires[i]);
		   msg_t->expires[i] = NULL;
		 } 
	       } else {
		 error(0, 0, "Despite the sizeinfo %d, no allocation at info %d", msgs->ns4__alert[i].__sizeinfo, j);
	       }
	     } else {
	       perror("Incomplete conversion of alert to text, discarding");
	       free(msg_t->alerts[i]);
	       free(msg_t->ids[i]);
	       goto error_inconsistent_msg_t;
	     }
	   } else {
	     if (difftime(*msg_t->expires[i],*(msgs->ns4__alert[i].info[j].expires)) < 0.) {
	       *(msg_t->expires[i]) = *(msgs->ns4__alert[i].info[j].expires);
	     }
	   }
	 }

	 // If there was no info block, make it expire in a week.
	 if (msg_t->expires[i] == NULL) {
	   msg_t->expires[i] = malloc(sizeof(time_t));
	   if (msg_t->expires[i])
	     *(msg_t->expires[i]) = msgs->ns4__alert[i].sent + 60*60*24*7;
	   else {
	     perror("Incomplete conversion of alert to text, discarding");
	     free(msg_t->alerts[i]);
	     free(msg_t->ids[i]);
	     goto error_inconsistent_msg_t;
	   }
	 }
       } else {
	 perror("Ran out of memory converting alert to text");
	 goto error_inconsistent_msg_t;
       }

       continue;
     error_inconsistent_msg_t:
       fclose(tmpf);
       if ( i > 0 ) {
	 msg_t->size = i;
	 return msg_t;
       } else {
	 perror("Unable to convert alerts to text [2]");
	 free(msg_t->expires);
	 free(msg_t->ids);
	 free(msg_t->alerts);
	 free(msg_t);
	 return NULL;
       }
     }

     return msg_t;
   } else {
     perror("Error retreiving alerts");
     return NULL;
   }
}
int main(int argc, char *argv[])
{
bmd_conf *konfiguracja=NULL;
struct soap soap;
char *serverURL = NULL;
char *host = NULL;
long int ssl_enabled=0;
long int authenticate=0;
char *keyfile=NULL;
char *keyfile_passwd=NULL;
char *keyfile_ssl=NULL;
char *keyfile_passwd_ssl=NULL;
char *cacert=NULL;
char *capath=NULL;
int status = 0;
struct bmd230__mtdsInfo *userMtds = NULL;
struct bmd230__searchResults *searchResults = NULL;
struct xsd__base64Binary *base64Cert = NULL;
char *serverResponse = NULL;
struct bmd230__mtdsValues *mtds = NULL;
struct bmd230__fileInfo *input = NULL;
GenBuf_t *tmp_file = NULL;
long int result=0;
char *file=NULL;
int i=0;
char *transactionId = NULL;
char *description=NULL;
int stream = 0;
FILE *fd = NULL;

	_GLOBAL_debug_level=0;
	if (argc==9)
	{
		for (i=1; i<argc; i++)
		{
			if (strcmp(argv[i],"-d")==0)
			{
				if (argc>i+1) _GLOBAL_debug_level=atoi(argv[i+1]);
			}
			if (strcmp(argv[i],"-p")==0)
			{
				if (argc>i+1) asprintf(&file,"%s",argv[i+1]);
			}
			if (strcmp(argv[i],"-t")==0)
			{
				if (argc>i+1) asprintf(&transactionId,"%s",argv[i+1]);
			}
			if (strcmp(argv[i],"-r")==0)
			{
				if (argc>i+1) asprintf(&description,"%s",argv[i+1]);
			}
		}
	}
	else
	{
		printf("%s\n",argv[0]);
		printf("\nniepoprawne wywołanie\n\nuzyj ponizszych parametrow\n");
		printf("-------------------------------------------------------\n");
		printf("\t-d liczba\tpoziom logowania\n");
		printf("\t-p nazwa\t\tnazwa katalogu\n");
		printf("\t-r opis\t\topis katalogu\n");
		printf("\t-t file\t\tid transakcji\n");
		printf("-------------------------------------------------------\n");
		return -1;
	}

	if (strcmp(transactionId,"0")==0)
	{
		printf("nulluje transakcje\n");
		free(transactionId); transactionId=NULL;
	}

	/*załadowanie bibliotek ssl-owych*/
	SSL_load_error_strings();
        SSL_library_init();

	/*funkcje konfiguracyjne*/
	load_soap_configuration(&konfiguracja);
	configuration(konfiguracja,&host,&keyfile,&keyfile_passwd,&keyfile_ssl,&keyfile_passwd_ssl,&cacert,&capath,&ssl_enabled);

	/*funkcja ustanowienia połaczenia z serwerem*/
	status=connection(&soap,ssl_enabled,authenticate,keyfile_ssl,keyfile_passwd_ssl,cacert,capath);
	if (status!=SOAP_OK)
	{
		PRINT_DEBUG("SOAPCLIENTERR Connection error\n");
		return 0;
	}

	/*przygotowanie danych niezbędnych do uruchomienia funkcji web-owej*/
	mtds = (struct bmd230__mtdsValues *)malloc(sizeof(struct bmd230__mtdsValues));
	mtds->__size = 2;
	mtds->__ptr = (struct bmd230__mtdsSingleValue *)malloc(sizeof(struct bmd230__mtdSingleValue)*mtds->__size);
	mtds->__ptr[0].mtdOid = "1.2.616.1.113527.4.3.3.8";
	mtds->__ptr[0].mtdValue = "lesioo";
	mtds->__ptr[0].mtdDesc = "";
	mtds->__ptr[1].mtdOid = OID_SYS_METADATA_CRYPTO_OBJECTS_CORESPONDING_ID;
	mtds->__ptr[1].mtdValue = "13";
	mtds->__ptr[1].mtdDesc = "";

// OID_SYS_METADATA_SEC_CAT
// OID_SYS_METADATA_BMD_SEC_LEVELS_STR

	GenBuf_t *cert_pem=NULL;
	base64Cert = (struct xsd__base64Binary *)malloc(sizeof(struct xsd__base64Binary));
	status = bmd_load_binary_content(keyfile,&cert_pem);
	if (status != BMD_OK)
	{
		PRINT_DEBUG("SOAPCLIENTERR Error while reading certificate file\n");
		return 0;
	}
	base64Cert->__ptr=cert_pem->buf;
	base64Cert->__size=cert_pem->size;

	soap_set_namespaces(&soap, bmd230_namespaces);

	/*przygotowanie pliku do wysyłki*/

        switch ( stream )
         {
            case 0 : {
// 	               status = bmd_load_binary_content(file,&tmp_file);
//
//                        if (status != 0)
//                         {
//                          printf("coś nie tak z plikiem :)\n");
//                          exit(-1);
//                         }
//
//                        input->file->__ptr=tmp_file->buf;
//                        input->file->__size=tmp_file->size;
//                        input->file->type=NULL;
//                        input->file->options=NULL;

                       /*********************************************************************************/
	               /************************ funkcja testowa ****************************************/
// 				status = soap_call_bmd230__bmdInsertFile(&soap, host, NULL, base64Cert, NULL, NULL, mtds, input, transactionId, nostream, &result);
				status = soap_call_bmd230__bmdCreateDirectory(&soap, host, NULL, base64Cert, NULL, NULL, NULL, mtds, description, file, transactionId, &result);
                       /*********************************************************************************/
                       /*********************************************************************************/

                       break;
                     }

            case 1 : {
                       soap_set_omode(&soap, SOAP_IO_CHUNK);
                       soap.fdimereadopen = dime_read_open;
                       soap.fdimereadclose = dime_read_close;
                       soap.fdimeread = dime_read;

                       fd = fopen(file, "r");

                       input->file->__ptr=(unsigned char*)fd;
                       input->file->__size=0;
                       input->file->type="";
                       input->file->options=soap_dime_option(&soap,0, strrchr(file,'/') ? strrchr(file,'/')+1 : file );

                       /*********************************************************************************/
	               /************************ funkcja testowa ****************************************/
//                        status = soap_call_bmd230__bmdInsertFile(&soap, host, NULL, base64Cert, NULL, NULL, mtds, input, transactionId, stream, &result);
                       /*********************************************************************************/
                       /*********************************************************************************/

                       break;
                     }

          default :  {
                       PRINT_ERROR("SOAPSERVERERR %s. Error=%i\n",GetErrorMsg(BMDSOAP_SERVER_INVALID_TRANSMISSION_TYPE),BMDSOAP_SERVER_INVALID_TRANSMISSION_TYPE);
                       soap_end(&soap);
                       soap_done(&soap);
                       free(serverURL);

                       return -1;
                     }
         }

	if (status == SOAP_OK)
	{
		/*********************************************************************************/
		/************************ funkcja odpowiedź ****************************************/
		printf("Katalog utworzony w archiwum; id %i\n",result);

		/*********************************************************************************/
		/*********************************************************************************/
	}
	else
	{
		/*odpowiedź w razie błędu*/
		soap_print_fault(&soap, stderr);
		soap_end(&soap);
		soap_done(&soap);
		free(serverURL);
		return -1;
	}


	soap_end(&soap);
	soap_done(&soap);
	free(serverURL);

	return 0;
}
Example #21
0
// the writer uses the fact that the primes class inherits the context:
void primes::write()
{
  soap_set_omode(this, SOAP_XML_INDENT); // show with indentation please
  soap_write_primes(this, this); // soap_write_prime is generated
}
Example #22
0
int ns__getClientUpdate(struct soap *soap, struct clientUpdateInfoRequest sClientUpdateInfo, struct clientUpdateResponse* lpsResponse)
{
	unsigned int er = erSuccess;
	ClientVersion sCurrentVersion = {0};
	ClientVersion sLatestVersion;
	unsigned int ulLicenseResponse = 0;
	unsigned char *lpLicenseResponse = NULL;
	ECLicenseClient *lpLicenseClient = NULL;
	std::string strClientMSIName;
	std::string strPath;
	FILE *fd = NULL;
	int res;
	unsigned int ulUserID = 0;
	ECSession *lpecSession = NULL;
	ECDatabase *lpDatabase = NULL;
	std::string strCurVersion;
	std::string strLatestVersion;
	std::string strQuery;
	time_t	tNow = 0;

	char *lpszClientUpdatePath = g_lpConfig->GetSetting("client_update_path");
	unsigned int ulLogLevel = atoui(g_lpConfig->GetSetting("client_update_log_level"));

	if (!parseBool(g_lpConfig->GetSetting("client_update_enabled"))) {
		// do not set on high loglevel, since by default the client updater is installed, and this will be quite often in your log
		g_lpLogger->Log(EC_LOGLEVEL_NOTICE, "Client update: trackid: 0x%08X, Config option 'client_update_enabled' has disabled this feature.", sClientUpdateInfo.ulTrackId);
		er = ZARAFA_E_NO_SUPPORT;
		goto exit;
	}

	// setup soap
	soap_set_imode(soap, SOAP_IO_KEEPALIVE | SOAP_C_UTFSTRING | SOAP_ENC_ZLIB | SOAP_ENC_MTOM);
	soap_set_omode(soap, SOAP_IO_KEEPALIVE | SOAP_C_UTFSTRING | SOAP_ENC_ZLIB | SOAP_ENC_MTOM | SOAP_IO_CHUNK);

	if (!lpszClientUpdatePath || lpszClientUpdatePath[0] == 0) {
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, The configuration field 'client_update_path' is empty.", sClientUpdateInfo.ulTrackId);
		er = ZARAFA_E_NO_ACCESS;
		goto exit;
	}

	er = g_lpSessionManager->CreateSessionInternal(&lpecSession);
	if(er != erSuccess)
		goto exit;

	// Lock the session
	lpecSession->Lock();

	er = lpecSession->GetDatabase(&lpDatabase);
	if (er != erSuccess)
		goto exit;

//@TODO change loglevel?
	g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, computername: %s, username: %s, clientversion: %s, windowsversion: %s, iplist: %s, soapip: %s", 
		sClientUpdateInfo.ulTrackId,
		(sClientUpdateInfo.szComputerName) ? sClientUpdateInfo.szComputerName : "-",
		(sClientUpdateInfo.szUsername) ? sClientUpdateInfo.szUsername : "-",
		(sClientUpdateInfo.szClientVersion) ? sClientUpdateInfo.szClientVersion : "-",
		(sClientUpdateInfo.szWindowsVersion) ? sClientUpdateInfo.szWindowsVersion : "-",
		(sClientUpdateInfo.szClientIPList) ? sClientUpdateInfo.szClientIPList : "-",
		PrettyIP(soap->ip).c_str() );

	if (!sClientUpdateInfo.szComputerName)
		sClientUpdateInfo.szComputerName = ""; //Client has no name?

	if(!sClientUpdateInfo.szUsername) {
		er = ZARAFA_E_NO_ACCESS;
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Client did not send a username", sClientUpdateInfo.ulTrackId);
	}

	// validate user name
	er = lpecSession->GetUserManagement()->SearchObjectAndSync(sClientUpdateInfo.szUsername, 0x01/*EMS_AB_ADDRESS_LOOKUP*/, &ulUserID);
	if (er != erSuccess) {
		er = ZARAFA_E_NO_ACCESS;
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, unknown username '%s'", sClientUpdateInfo.ulTrackId, sClientUpdateInfo.szUsername);
	}


	if(lpecSession->GetUserManagement()->IsInternalObject(ulUserID)) {
		er = ZARAFA_E_NO_ACCESS;
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Wrong user data. User name '%s' is a reserved user", sClientUpdateInfo.ulTrackId, sClientUpdateInfo.szUsername);
		goto exit;
	}

	// Check if the user connect to the right server, else redirect
	if (lpecSession->GetSessionManager()->IsDistributedSupported() ) 
	{
		objectdetails_t sUserDetails;

		er = lpecSession->GetUserManagement()->GetObjectDetails(ulUserID, &sUserDetails);
		if (er != erSuccess)
			goto exit;

		/* Check if this is the correct server */
		string strServerName = sUserDetails.GetPropString(OB_PROP_S_SERVERNAME);
		if (strServerName.empty()) {
			g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, User '%s' has no default server", sClientUpdateInfo.ulTrackId, sClientUpdateInfo.szUsername);
			er = ZARAFA_E_NO_ACCESS;
			goto exit;
		}

		if (stricmp(strServerName.c_str(), g_lpSessionManager->GetConfig()->GetSetting("server_name")) != 0) {
			string	strServerPath;

			er = GetBestServerPath(soap, lpecSession, strServerName, &strServerPath);
			if (er != erSuccess)
				goto exit;

			lpsResponse->lpszServerPath = s_strcpy(soap, strServerPath.c_str());// Server Path must always utf8 (also in 6.40.x)
			g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_INFO, "Client update: trackid: 0x%08X, User '%s' is redirected to '%s'", sClientUpdateInfo.ulTrackId, sClientUpdateInfo.szUsername, lpsResponse->lpszServerPath);
			g_lpStatsCollector->Increment(SCN_REDIRECT_COUNT, 1);
			er = ZARAFA_E_UNABLE_TO_COMPLETE;
			goto exit;
		}
	}

	lpLicenseClient = new ECLicenseClient(g_lpConfig->GetSetting("license_socket"),  atoui(g_lpConfig->GetSetting("license_timeout")));
	er = lpLicenseClient->Auth(sClientUpdateInfo.sLicenseReq.__ptr, sClientUpdateInfo.sLicenseReq.__size, &lpLicenseResponse, &ulLicenseResponse);
	if (er != erSuccess) {
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Invalid license request, error: 0x%08X.", sClientUpdateInfo.ulTrackId, er);
		goto exit;
	}

	if (sClientUpdateInfo.szClientVersion == NULL || sClientUpdateInfo.szClientVersion[0] == '\0') {
		g_lpLogger->Log(EC_LOGLEVEL_INFO, "Client update: trackid: 0x%08X, The client did not sent the current version number.", sClientUpdateInfo.ulTrackId);
	} else if (!GetVersionFromString(sClientUpdateInfo.szClientVersion, &sCurrentVersion)) {
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Failed in getting version from input data.", sClientUpdateInfo.ulTrackId);
		goto exit; //@fixme can we give the latest?
	}

	if (!GetLatestVersionAtServer(lpszClientUpdatePath, sClientUpdateInfo.ulTrackId, &sLatestVersion)) {
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, No updates found on server.", sClientUpdateInfo.ulTrackId);
		er = ZARAFA_E_NO_ACCESS;
		goto exit;
	}

	res = CompareVersions(sCurrentVersion, sLatestVersion);
	if (res == 0) {
		g_lpLogger->Log(EC_LOGLEVEL_INFO, "Client update: trackid: 0x%08X, Client already has the latest version.", sClientUpdateInfo.ulTrackId);
		goto ok;
	} else if (res > 0) {
		g_lpLogger->Log(EC_LOGLEVEL_INFO, "Client update: trackid: 0x%08X, Client has newer version than server.", sClientUpdateInfo.ulTrackId);
		goto ok;
	}

	if (!GetClientMSINameFromVersion(sLatestVersion, &strClientMSIName)) {
		g_lpLogger->Log(EC_LOGLEVEL_INFO, "Client update: trackid: 0x%08X, No suitable version available.", sClientUpdateInfo.ulTrackId);
		er = ZARAFA_E_NO_ACCESS;
		goto exit;
	}

	if (ConvertAndValidatePath(lpszClientUpdatePath, strClientMSIName, &strPath) != true) {
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Error in path conversion and validation.", sClientUpdateInfo.ulTrackId);
		er = ZARAFA_E_NO_ACCESS;
		goto exit;
	}

	fd = fopen(strPath.c_str(), "rb");
	if (!fd) {
		g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Path not found %s.", sClientUpdateInfo.ulTrackId, strPath.c_str());
		er = ZARAFA_E_NO_ACCESS;
		goto exit;
	}

	// Update auto update client status
	VersionToString(sCurrentVersion, &strCurVersion);
	VersionToString(sLatestVersion, &strLatestVersion);

	tNow = time(NULL); // Get current time

	strQuery = "REPLACE INTO clientupdatestatus(userid, trackid, updatetime, currentversion, latestversion, computername, status) VALUES ("+
				stringify(ulUserID)+", "+stringify(sClientUpdateInfo.ulTrackId)+", FROM_UNIXTIME("+
				stringify(tNow) + "), \"" + strCurVersion + "\", \"" + strLatestVersion + "\", \"" +
				lpDatabase->Escape(sClientUpdateInfo.szComputerName).c_str()+"\", "+ stringify(UPDATE_STATUS_PENDING) + ")";

	// ignore error in database tracking, SQL error logged in server, still send new client
	lpDatabase->DoUpdate(strQuery);

	soap->fmimereadopen = &mime_file_read_open;
	soap->fmimeread = &mime_file_read;
	soap->fmimereadclose = &mime_file_read_close;

	// Setup the MTOM Attachments
	lpsResponse->sStreamData.xop__Include.__ptr = (unsigned char*)fd;
	lpsResponse->sStreamData.xop__Include.__size = 0;
	lpsResponse->sStreamData.xop__Include.type = s_strcpy(soap, "application/binary");
	lpsResponse->sStreamData.xop__Include.id = s_strcpy(soap, "zarafaclient");

	g_lpLogger->Log(EC_LOGLEVEL_ERROR, "Client update: trackid: 0x%08X, Sending new installer %s", sClientUpdateInfo.ulTrackId, strClientMSIName.c_str());

ok: // Client is already up to date
	lpsResponse->sLicenseResponse.__size = ulLicenseResponse;
	lpsResponse->sLicenseResponse.__ptr = (unsigned char *)s_memcpy(soap, (const char *)lpLicenseResponse, ulLicenseResponse);
	
	lpsResponse->ulLogLevel = ulLogLevel; // 0 = none, 1 = on errors, 2 = always
	
exit:
	if(lpecSession) {
		lpecSession->Unlock(); 
		g_lpSessionManager->RemoveSessionInternal(lpecSession);
	}

	lpsResponse->er = er;

	if (lpLicenseResponse)
		delete [] lpLicenseResponse;

	if (lpLicenseClient)
		delete lpLicenseClient;

	if (er && fd)
		fclose(fd);

	return SOAP_OK;
}
Example #23
0
int main(int argc, char **argv)
{ 
	struct soap soap;
	struct SOAP_ENV__Header header;
//	struct wsa__EndpointReferenceType replyTo;
//	char *res;
	char *mid0 = "packet0";
	char *mid1 = "packet1";

	soap_init(&soap);

	soap.send_timeout = 10;
	soap.recv_timeout = 10;

	/* To compress the request message (compile with -DWITH_GZIP): */
	#ifdef WITH_GZIP
	soap_set_omode(&soap, SOAP_ENC_ZLIB);
	#endif

	/* To transmit MIME attachments:
	soap_set_mime(&soap, NULL, NULL);
	soap_set_mime_attachment(&soap, "abc", 3, SOAP_MIME_7BIT, "text/xml", "cid:abc", NULL, NULL);
	*/

	/* To transmit DIME attachments:
	soap_set_dime(&soap);
	soap_set_dime_attachment(&soap, "abc", 3, "cid:abc", "text/xml", 0, NULL);
	*/

	///* Prepare SOAP Header */
	//soap_default_SOAP_ENV__Header(&soap, &header);
	//soap.header = &header;

	//soap_default_wsa__EndpointReferenceType(&soap, &replyTo);
	//replyTo.Address = "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous";

	///* Set WS-Addressing elements for request-response unicast */
	//header.wsa__MessageID = mid0;
	//header.wsa__To = "http://genivia.com/udp/server";
	//header.wsa__Action = "http://genivia.com/udp/echoString";
	//header.wsa__ReplyTo = &replyTo;

	///* Make request-response call */
	//if (soap_call_ns__echoString(&soap, NULL, NULL, "hello world!", &res))
	//{ 
	//	if (soap.error == SOAP_EOF && soap.errnum == 0)
	//	printf("Timeout: message probably already delivered\n");
	//else
	//	soap_print_fault(&soap, stderr);
	//}
	//else
	//	printf("UDP server response: %s\n", res);

	for (int packet_id = 0;; packet_id =(packet_id ? 0 : 1) )
	{
		/* Reset the SOAP Header */
		soap_default_SOAP_ENV__Header(&soap, &header);
		soap.header = &header;

		/* Set WS-Addressing elements for one-way unicast */
		if (0 == packet_id)
			header.wsa__MessageID = mid0;
		else
			header.wsa__MessageID = mid1;
		header.wsa__To = "http://genivia.com/udp/server";
		header.wsa__Action = "http://genivia.com/udp/sendString";

		/* Send one-way message */
		if (soap_send_ns__sendString(&soap, SERVER_ADDRESS, NULL, "ABET!"))
			soap_print_fault(&soap, stderr);

		soap_destroy(&soap);
		soap_end(&soap);

		//Spacing between packet0 and packet1
		Sleep(SPACING_IN);
	}
	
	soap_done(&soap);
	return 0;
}
Example #24
0
int main(int argc, char **argv)
{ struct soap *soap;
  int server = 0;
  int text = 0;
  int port = 0;
  FILE *fd;
  double result;
  char *user;
  int runs = 1;
  /* create context */
  soap = soap_new();
  /* register wsse plugin */
  soap_register_plugin_arg(soap, soap_wsse, (void*)token_handler);
  /* options */
  if (argc >= 2)
  { if (strchr(argv[1], 'c'))
      soap_set_omode(soap, SOAP_IO_CHUNK);
    else if (strchr(argv[1], 'y'))
      soap_set_omode(soap, SOAP_IO_STORE);
    if (strchr(argv[1], 'i'))
      soap_set_omode(soap, SOAP_XML_INDENT);
    if (strchr(argv[1], 'n'))
      soap_set_omode(soap, SOAP_XML_CANONICAL);
    if (strchr(argv[1], 'a'))
      aes = 1;
    if (strchr(argv[1], 'o'))
      oaep = 1;
    if (strchr(argv[1], 'd'))
      sym = 1;
    if (strchr(argv[1], 'e'))
      enc = 1;
    if (strchr(argv[1], 'f'))
      addenc = 1;
    /* if (strchr(argv[1], 'F'))
      addenca = 1; */
    if (strchr(argv[1], 'h'))
      hmac = 1;
    if (strchr(argv[1], 'k'))
      nokey = 1;
    if (strchr(argv[1], 's'))
      server = 1;
    if (strchr(argv[1], 't'))
      text = 1;
    if (strchr(argv[1], 'g'))
      addsig = 1;
    if (strchr(argv[1], 'b'))
      nobody = 1;
    if (strchr(argv[1], 'x'))
      nohttp = 1;
    if (strchr(argv[1], 'z'))
      soap_set_mode(soap, SOAP_ENC_ZLIB);
    if (isdigit(argv[1][strlen(argv[1])-1]))
    { runs = argv[1][strlen(argv[1])-1] - '0';
      soap_set_mode(soap, SOAP_IO_KEEPALIVE);
    }
  }
  /* soap->actor = "..."; */ /* set only when required */
  user = getenv("USER");
  if (!user)
    user = "anyone";
  /* read RSA private key for signing */
  if ((fd = fopen("server.pem", "r")))
  { rsa_privk = PEM_read_PrivateKey(fd, NULL, NULL, (void*)"password");
    fclose(fd);
    if (!rsa_privk)
    { fprintf(stderr, "Could not read private RSA key from server.pem\n");
      exit(1);
    }
  }
  else
    fprintf(stderr, "Could not read server.pem\n");
  /* read certificate (more efficient is to keep certificate in memory)
     to obtain public key for encryption and signature verification */
  if ((fd = fopen("servercert.pem", "r")))
  { cert = PEM_read_X509(fd, NULL, NULL, NULL);
    fclose(fd);
    if (!cert)
    { fprintf(stderr, "Could not read certificate from servercert.pem\n");
      exit(1);
    }
  }
  else
    fprintf(stderr, "Could not read server.pem\n");
  rsa_pubk = X509_get_pubkey(cert);
  if (!rsa_pubk)
  { fprintf(stderr, "Could not get public key from certificate\n");
    exit(1);
  }
  /* port argument */
  if (argc >= 3)
    port = atoi(argv[2]);
  /* need cacert to verify certificates with CA (cacert.pem for testing and
     cacerts.pem for production, which contains the trusted CA certificates) */
  soap->cafile = "cacert.pem";
  /* server or client/ */
  if (server)
  { if (port)
    { /* stand-alone server serving messages over port */
      if (!soap_valid_socket(soap_bind(soap, NULL, port, 100)))
      { soap_print_fault(soap, stderr);
        exit(1);
      }
      printf("Server started at port %d\n", port);
      while (soap_valid_socket(soap_accept(soap)))
      { if (hmac)
          soap_wsse_verify_auto(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
        else if (nokey)
          soap_wsse_verify_auto(soap, SOAP_SMD_VRFY_RSA_SHA1, rsa_pubk, 0);
        else
          soap_wsse_verify_auto(soap, SOAP_SMD_NONE, NULL, 0);
        if (sym)
        { if (aes)
            soap_wsse_decrypt_auto(soap, SOAP_MEC_DEC_AES256_CBC, aes_key, sizeof(aes_key));
	  else
	    soap_wsse_decrypt_auto(soap, SOAP_MEC_DEC_DES_CBC, des_key, sizeof(des_key));
        }
        else if (enc)
          soap_wsse_decrypt_auto(soap, SOAP_MEC_ENV_DEC_DES_CBC, rsa_privk, 0);
        if (soap_serve(soap))
        { soap_wsse_delete_Security(soap);
          soap_print_fault(soap, stderr);
          soap_print_fault_location(soap, stderr);
        }
	soap_destroy(soap);
	soap_end(soap);
      }
      soap_print_fault(soap, stderr);
      exit(1);
    }
    else
    { /* CGI-style server serving messages over stdin/out */
      if (hmac)
        soap_wsse_verify_auto(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
      else if (nokey)
        soap_wsse_verify_auto(soap, SOAP_SMD_VRFY_RSA_SHA1, rsa_pubk, 0);
      else
        soap_wsse_verify_auto(soap, SOAP_SMD_NONE, NULL, 0);
      if (sym)
      { if (aes)
          soap_wsse_decrypt_auto(soap, SOAP_MEC_DEC_AES256_CBC, aes_key, sizeof(aes_key));
	else
	  soap_wsse_decrypt_auto(soap, SOAP_MEC_DEC_DES_CBC, des_key, sizeof(des_key));
      }
      else if (enc)
        soap_wsse_decrypt_auto(soap, SOAP_MEC_ENV_DEC_DES_CBC, rsa_privk, 0);
      if (soap_serve(soap))
      { soap_wsse_delete_Security(soap);
        soap_print_fault(soap, stderr);
        soap_print_fault_location(soap, stderr);
      }
      soap_destroy(soap);
      soap_end(soap);
    }
  }
  else /* client */
  { int run;
    char endpoint[80];
    /* ns1:test data */
    struct ns1__add a;
    struct ns1__sub b;
    a.a = 123;
    a.b = 456;
    b.a = 789;
    b.b = -99999;
    /* client sending messages to stdout or over port */
    if (port)
      sprintf(endpoint, "http://localhost:%d", port);
    else if (nohttp)
      strcpy(endpoint, "");
    else
      strcpy(endpoint, "http://");

    for (run = 0; run < runs; run++)
    {

    /* message lifetime of 60 seconds */
    soap_wsse_add_Timestamp(soap, "Time", 60);
    /* add user name with text or digest password */
    if (text)
      soap_wsse_add_UsernameTokenText(soap, "User", user, "userPass");
    else
      soap_wsse_add_UsernameTokenDigest(soap, "User", user, "userPass");
    if (sym)
    { if (aes)
      { /* symmetric encryption with AES */
        soap_wsse_add_EncryptedData_KeyInfo_KeyName(soap, "My AES Key");
        if (soap_wsse_encrypt_body(soap, SOAP_MEC_ENC_AES256_CBC, aes_key, sizeof(aes_key)))
          soap_print_fault(soap, stderr);
        soap_wsse_decrypt_auto(soap, SOAP_MEC_DEC_AES256_CBC, aes_key, sizeof(aes_key));
      }
      else
      { /* symmetric encryption with DES */
        soap_wsse_add_EncryptedData_KeyInfo_KeyName(soap, "My DES Key");
        if (soap_wsse_encrypt_body(soap, SOAP_MEC_ENC_DES_CBC, des_key, sizeof(des_key)))
          soap_print_fault(soap, stderr);
        soap_wsse_decrypt_auto(soap, SOAP_MEC_DEC_DES_CBC, des_key, sizeof(des_key));
      }
    }
    else if (addenc || addenca)
    { /* RSA encryption of the <ns1:add> element */
      const char *SubjectKeyId = NULL; /* set to non-NULL to use SubjectKeyIdentifier in Header rather than a full cert key */
      /* MUST set wsu:Id of the elements to encrypt */
      if (addenc) /* encrypt element <ns1:add> */
      { soap_wsse_set_wsu_id(soap, "ns1:add");
        if (soap_wsse_add_EncryptedKey_encrypt_only(soap, SOAP_MEC_ENV_ENC_DES_CBC, "Cert", cert, SubjectKeyId, NULL, NULL, "ns1:add"))
          soap_print_fault(soap, stderr);
      }
      else /* encrypt element <a> */
      { soap_wsse_set_wsu_id(soap, "a");
        if (soap_wsse_add_EncryptedKey_encrypt_only(soap, SOAP_MEC_ENV_ENC_DES_CBC, "Cert", cert, SubjectKeyId, NULL, NULL, "a"))
          soap_print_fault(soap, stderr);
      }
      soap_wsse_decrypt_auto(soap, SOAP_MEC_ENV_DEC_DES_CBC, rsa_privk, 0);
    }
    else if (enc)
    { /* RSA encryption of the SOAP Body */
      const char *SubjectKeyId = NULL; /* set to non-NULL to use SubjectKeyIdentifier in Header rather than a full cert key */
      if (oaep)
      { if (soap_wsse_add_EncryptedKey(soap, SOAP_MEC_ENV_ENC_AES256_CBC | SOAP_MEC_OAEP, "Cert", cert, SubjectKeyId, NULL, NULL))
          soap_print_fault(soap, stderr);
      }
      else if (aes)
      { if (soap_wsse_add_EncryptedKey(soap, SOAP_MEC_ENV_ENC_AES256_CBC, "Cert", cert, SubjectKeyId, NULL, NULL))
          soap_print_fault(soap, stderr);
      }
      else
      { if (soap_wsse_add_EncryptedKey(soap, SOAP_MEC_ENV_ENC_DES_CBC, "Cert", cert, SubjectKeyId, NULL, NULL))
          soap_print_fault(soap, stderr);
      }
      soap_wsse_decrypt_auto(soap, SOAP_MEC_ENV_DEC_DES_CBC, rsa_privk, 0);
    }
    if (hmac)
    { /* symmetric signature */
      if (nobody)
        soap_wsse_sign(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
      else
        soap_wsse_sign_body(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
      /* WS-SecureConversation contect token */
      soap_wsse_add_SecurityContextToken(soap, "SCT", contextId);
    }
    else
    { if (nokey)
        soap_wsse_add_KeyInfo_KeyName(soap, "MyKey");
      else
      { soap_wsse_add_BinarySecurityTokenX509(soap, "X509Token", cert);
        soap_wsse_add_KeyInfo_SecurityTokenReferenceX509(soap, "#X509Token");
      }
      if (nobody || addsig) /* do not sign body */
        soap_wsse_sign(soap, SOAP_SMD_SIGN_RSA_SHA1, rsa_privk, 0);
      else
        soap_wsse_sign_body(soap, SOAP_SMD_SIGN_RSA_SHA256, rsa_privk, 0);
    }
    /* enable automatic signature verification of server responses */
    if (hmac)
      soap_wsse_verify_auto(soap, SOAP_SMD_HMAC_SHA1, hmac_key, sizeof(hmac_key));
    else if (nokey)
      soap_wsse_verify_auto(soap, SOAP_SMD_VRFY_RSA_SHA1, rsa_pubk, 0);
    else
      soap_wsse_verify_auto(soap, SOAP_SMD_NONE, NULL, 0);
    /* sign the response message in unsigned body? If so, set wsu:Id */
    if (addsig)
    { soap_wsse_set_wsu_id(soap, "ns1:add");
      soap_wsse_sign_only(soap, "User ns1:add");
    }
    /* invoke the server. You can choose add, sub, mul, or div operations
     * that show different security aspects (intentional message rejections)
     * for demonstration purposes (see server operations below) */
    if (!soap_call_ns1__add(soap, endpoint, NULL, 1.0, 2.0, &result))
    { if (!soap_wsse_verify_Timestamp(soap))
      { const char *servername = soap_wsse_get_Username(soap);
        if (servername
	 && !strcmp(servername, "server")
         && !soap_wsse_verify_Password(soap, "serverPass"))
          printf("Result = %g\n", result);
        else
	{ fprintf(stderr, "Server authentication failed\n");
          soap_print_fault(soap, stderr);
        }
      }
      else
      { fprintf(stderr, "Server response expired\n");
        soap_print_fault(soap, stderr);
      }
    }
    else
    { soap_print_fault(soap, stderr);
      soap_print_fault_location(soap, stderr);
    }
    /* clean up security header */
    soap_wsse_delete_Security(soap);
    /* disable soap_wsse_verify_auto */
    soap_wsse_verify_done(soap);

  } /* run */

  }
  /* clean up keys */
  if (rsa_privk)
    EVP_PKEY_free(rsa_privk);
  if (rsa_pubk)
    EVP_PKEY_free(rsa_pubk);
  if (cert)
    X509_free(cert);
  /* clean up gSOAP engine */
  soap_destroy(soap);
  soap_end(soap);
  soap_done(soap);
  free(soap);
  /* done */
  return 0;
}
Example #25
0
inline void innersimpleGsoap10()
{
	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__outersimpleGsoap10 input, output;
	input.soap = soap;

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

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

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

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

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

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

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

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

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

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

	input.att1 = &inner1;
	input.att2 = &inner2;
	input.att3 = &inner3;
	input.att4 = &inner4;
	input.att5 = &inner5;
	input.att6 = &inner6;
	input.att7 = &inner7;
	input.att8 = &inner8;
	input.att9 = &inner9;
	input.att10 = &inner10;

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

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

		soap_read__ns1__outersimpleGsoap10(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Example #26
0
inline void innercomplexGsoap5()
{
	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__outercomplexGsoap5 input, output;
	input.soap = soap;

	ns1__innercomplexGsoap5 inner1;
	inner1.soap = soap;
	inner1.att1 = 0;
	inner1.att2 = 1;
	inner1.att3 = 2;
	inner1.att4 = 3;
	inner1.att5 = 4;
	inner1.att6 = 0;
	inner1.att7 = 1;
	inner1.att8 = 2;
	inner1.att9 = 3;
	inner1.att10 = 4;
	inner1.att11 = "TEST 0";
	inner1.att12 = "TEST 1";
	inner1.att13 = "TEST 2";
	inner1.att14 = "TEST 3";
	inner1.att15 = "TEST 4";
	inner1.att16 = 1.5;
	inner1.att17 = 2.6;
	inner1.att18 = 3.7;
	inner1.att19 = 4.8;
	inner1.att20 = 5.9;
	inner1.att21 = 10.0;
	inner1.att22 = 11.1;
	inner1.att23 = 12.2;
	inner1.att24 = 13.3;
	inner1.att25 = 14.4;
	inner1.att26 = true;
	inner1.att27 = true;
	inner1.att28 = true;
	inner1.att29 = true;
	inner1.att30 = true;

	ns1__innercomplexGsoap5 inner2;
	inner2.soap = soap;
	inner2.att1 = 0;
	inner2.att2 = 1;
	inner2.att3 = 2;
	inner2.att4 = 3;
	inner2.att5 = 4;
	inner2.att6 = 0;
	inner2.att7 = 1;
	inner2.att8 = 2;
	inner2.att9 = 3;
	inner2.att10 = 4;
	inner2.att11 = "TEST 0";
	inner2.att12 = "TEST 1";
	inner2.att13 = "TEST 2";
	inner2.att14 = "TEST 3";
	inner2.att15 = "TEST 4";
	inner2.att16 = 1.5;
	inner2.att17 = 2.6;
	inner2.att18 = 3.7;
	inner2.att19 = 4.8;
	inner2.att20 = 5.9;
	inner2.att21 = 10.0;
	inner2.att22 = 11.1;
	inner2.att23 = 12.2;
	inner2.att24 = 13.3;
	inner2.att25 = 14.4;
	inner2.att26 = true;
	inner2.att27 = true;
	inner2.att28 = true;
	inner2.att29 = true;
	inner2.att30 = true;

	ns1__innercomplexGsoap5 inner3;
	inner3.soap = soap;
	inner3.att1 = 0;
	inner3.att2 = 1;
	inner3.att3 = 2;
	inner3.att4 = 3;
	inner3.att5 = 4;
	inner3.att6 = 0;
	inner3.att7 = 1;
	inner3.att8 = 2;
	inner3.att9 = 3;
	inner3.att10 = 4;
	inner3.att11 = "TEST 0";
	inner3.att12 = "TEST 1";
	inner3.att13 = "TEST 2";
	inner3.att14 = "TEST 3";
	inner3.att15 = "TEST 4";
	inner3.att16 = 1.5;
	inner3.att17 = 2.6;
	inner3.att18 = 3.7;
	inner3.att19 = 4.8;
	inner3.att20 = 5.9;
	inner3.att21 = 10.0;
	inner3.att22 = 11.1;
	inner3.att23 = 12.2;
	inner3.att24 = 13.3;
	inner3.att25 = 14.4;
	inner3.att26 = true;
	inner3.att27 = true;
	inner3.att28 = true;
	inner3.att29 = true;
	inner3.att30 = true;

	ns1__innercomplexGsoap5 inner4;
	inner4.soap = soap;
	inner4.att1 = 0;
	inner4.att2 = 1;
	inner4.att3 = 2;
	inner4.att4 = 3;
	inner4.att5 = 4;
	inner4.att6 = 0;
	inner4.att7 = 1;
	inner4.att8 = 2;
	inner4.att9 = 3;
	inner4.att10 = 4;
	inner4.att11 = "TEST 0";
	inner4.att12 = "TEST 1";
	inner4.att13 = "TEST 2";
	inner4.att14 = "TEST 3";
	inner4.att15 = "TEST 4";
	inner4.att16 = 1.5;
	inner4.att17 = 2.6;
	inner4.att18 = 3.7;
	inner4.att19 = 4.8;
	inner4.att20 = 5.9;
	inner4.att21 = 10.0;
	inner4.att22 = 11.1;
	inner4.att23 = 12.2;
	inner4.att24 = 13.3;
	inner4.att25 = 14.4;
	inner4.att26 = true;
	inner4.att27 = true;
	inner4.att28 = true;
	inner4.att29 = true;
	inner4.att30 = true;

	ns1__innercomplexGsoap5 inner5;
	inner5.soap = soap;
	inner5.att1 = 0;
	inner5.att2 = 1;
	inner5.att3 = 2;
	inner5.att4 = 3;
	inner5.att5 = 4;
	inner5.att6 = 0;
	inner5.att7 = 1;
	inner5.att8 = 2;
	inner5.att9 = 3;
	inner5.att10 = 4;
	inner5.att11 = "TEST 0";
	inner5.att12 = "TEST 1";
	inner5.att13 = "TEST 2";
	inner5.att14 = "TEST 3";
	inner5.att15 = "TEST 4";
	inner5.att16 = 1.5;
	inner5.att17 = 2.6;
	inner5.att18 = 3.7;
	inner5.att19 = 4.8;
	inner5.att20 = 5.9;
	inner5.att21 = 10.0;
	inner5.att22 = 11.1;
	inner5.att23 = 12.2;
	inner5.att24 = 13.3;
	inner5.att25 = 14.4;
	inner5.att26 = true;
	inner5.att27 = true;
	inner5.att28 = true;
	inner5.att29 = true;
	inner5.att30 = 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;
	input.att8 = 2;
	input.att9 = "TEST 2";
	input.att10 = &inner2;
	input.att11 = 11.7;
	input.att12 = 3.19;
	input.att13 = false;
	input.att14 = "TEST 3";
	input.att15 = &inner3;
	input.att16 = 12.8;
	input.att17 = 4.20;
	input.att18 = false;
	input.att19 = &inner4;
	input.att20 = 13.9;
	input.att21 = 5.21;
	input.att22 = false;
	input.att23 = 14.10;
	input.att24 = 6.22;
	input.att25 = 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__outercomplexGsoap5(soap, &input);

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

		soap_read__ns1__outercomplexGsoap5(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}
Example #27
0
inline void complexGsoap10()
{
	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__complexGsoap10 input, output;
	input.soap = soap;
	input.att1 = 0;
	input.att2 = 1;
	input.att3 = 2;
	input.att4 = 3;
	input.att5 = 4;
	input.att6 = 5;
	input.att7 = 6;
	input.att8 = 7;
	input.att9 = 8;
	input.att10 = 9;
	input.att11 = 0;
	input.att12 = 1;
	input.att13 = 2;
	input.att14 = 3;
	input.att15 = 4;
	input.att16 = 5;
	input.att17 = 6;
	input.att18 = 7;
	input.att19 = 8;
	input.att20 = 9;
	input.att21 = "TEST 0";
	input.att22 = "TEST 1";
	input.att23 = "TEST 2";
	input.att24 = "TEST 3";
	input.att25 = "TEST 4";
	input.att26 = "TEST 5";
	input.att27 = "TEST 6";
	input.att28 = "TEST 7";
	input.att29 = "TEST 8";
	input.att30 = "TEST 9";
	input.att31 = 2.5;
	input.att32 = 3.6;
	input.att33 = 4.7;
	input.att34 = 5.8;
	input.att35 = 6.9;
	input.att36 = 7.10;
	input.att37 = 8.11;
	input.att38 = 9.12;
	input.att39 = 10.13;
	input.att40 = 11.14;
	input.att41 = 27.1;
	input.att42 = 28.2;
	input.att43 = 29.3;
	input.att44 = 30.4;
	input.att45 = 31.5;
	input.att46 = 32.6;
	input.att47 = 33.7;
	input.att48 = 34.8;
	input.att49 = 35.9;
	input.att50 = 36.10;
	input.att51 = true;
	input.att52 = true;
	input.att53 = true;
	input.att54 = true;
	input.att55 = true;
	input.att56 = true;
	input.att57 = true;
	input.att58 = true;
	input.att59 = true;
	input.att60 = 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__complexGsoap10(soap, &input);

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

		soap_read__ns1__complexGsoap10(soap, &output);
	}

	soap_destroy(soap);
	soap_end(soap);
	soap_done(soap);
}