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); }
int main(int argc, char* argv[]) { int m, s; /**//* master and slave sockets */ struct soap sop; soap_init(&sop); if (argc < 2) { printf("usage:%s <server_port>\n", argv[0]); goto failed; } m = soap_bind(&sop, NULL, atoi(argv[1]), 100); if (m < 0) { soap_print_fault(&sop, stderr); goto failed; } fprintf(stderr, "Socket connection successful: master socket = %d\n", m); for ( ; ; ) { s = soap_accept(&sop); if (s < 0) { soap_print_fault(&sop, stderr); goto failed; } fprintf(stderr, "Socket connection successful: slave socket = %d\n", s); soap_serve(&sop); soap_end(&sop); } return 0; failed: return 1; }
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); }
/** * gSOAP */ static void init_gsoap (struct soap *p_soap) { /* Initialize gSOAP */ soap_init (p_soap); soap_set_namespaces (p_soap, simias_namespaces); }
int main(int argc, char**argv) { struct soap soap; int m, s; size = 0; soap_init(&soap); m = soap_bind(&soap, hostname, port, 100); if (m < 0) soap_print_fault(&soap, stderr); else { fprintf(stderr, "Socket connection successful: master socket = %d; port = %d\n", m, port); int i; for (i = 1; ; i++) { s = soap_accept(&soap); if (s < 0) { soap_print_fault(&soap, stderr); break; } fprintf(stderr, "%d: accepted connection from IP=%d.%d.%d.%d socket=%d", i, (soap.ip >> 24)&0xFF, (soap.ip >> 16)&0xFF, (soap.ip >> 8)&0xFF, soap.ip&0xFF, s); if (soap_serve(&soap) != SOAP_OK) soap_print_fault(&soap, stderr); fprintf(stderr, "request served\n"); soap_destroy(&soap); soap_end(&soap); } } soap_done(&soap); }
//srm_array_of_strings getProtocols( srm_host_info host_info ); // RequestStatus getRequestStatus( srm_int requestId, srm_host_info host_info ) { char srmurl[SRM_MAX_URL_LEN]; RequestStatus rs = NULL; if( fillSrmUrl( srmurl, host_info) ) { int ret; class tns__getRequestStatusResponse out; { struct soap soap; soap_init(&soap); ret = soap_call_tns__getRequestStatus( &soap, (const char*)srmurl, "getRequestStatus", (int)requestId, &out ); if ( ret ) soap_print_fault( &soap, stderr ); else rs = g2srm_RequestStatus( out._Result ); soap_end( &soap ); soap_done( &soap ); } } return rs; }
RequestStatus get( srm_array_of_strings surls, srm_array_of_strings protocols, srm_host_info host_info ) { char srmurl[SRM_MAX_URL_LEN]; RequestStatus rs = NULL; if( fillSrmUrl( srmurl, host_info) ) { int ret; class tns__getResponse out; class ArrayOfstring *arg0 = srm2g_string_array( surls ); class ArrayOfstring *arg1 = srm2g_string_array( protocols ); { struct soap soap; soap_init( &soap ); ret = soap_call_tns__get ( &soap, (const char*)srmurl, "get", arg0, arg1, &out); if ( ret == SOAP_OK ) rs = g2srm_RequestStatus( out._Result ); else soap_print_fault( &soap, stderr ); soap_end( &soap ); soap_done( &soap ); } freeArrayOfstring( arg0 ); freeArrayOfstring( arg1 ); } return rs; }
CWebServiceApi::CWebServiceApi() { m_soap_endpoint = ""; soap_init(&clientSOAP); setlocale(LC_ALL,"chs"); soap_set_mode(&clientSOAP,SOAP_C_MBSTRING); }
RequestStatus setFileStatus ( srm_int requestId, srm_int fileId, srm_string state, srm_host_info host_info ) { char *statestr = (char*) state; char srmurl[SRM_MAX_URL_LEN]; class tns__setFileStatusResponse out; RequestStatus rs = NULL; if( strcmp("Failed", statestr) && strcmp("Pending", statestr) && strcmp("Ready", statestr) && strcmp("Running", statestr) && strcmp("Done", statestr) ) return NULL; /* String NOT found, the state is invalid, just do nothing */ if( fillSrmUrl( srmurl, host_info) ) { struct soap soap; soap_init(&soap); if ( soap_call_tns__setFileStatus ( &soap, (const char*)srmurl, "setFileStatus", (int)requestId, (int)fileId, state, &out)) soap_print_fault( &soap, stderr ); else rs = g2srm_RequestStatus( out._Result ); soap_end( &soap ); soap_done( &soap ); } return rs; }
static int rmc_init (struct soap *soap, char *errbuf, int errbufsz) { int flags; soap_init (soap); soap->namespaces = namespaces_rmc; if (rmc_endpoint == NULL && (rmc_endpoint = getenv ("RMC_ENDPOINT")) == NULL) { if (!gfal_is_nobdii ()) { if (get_rls_endpoints (&lrc_endpoint, &rmc_endpoint, errbuf, errbufsz) != 0) { errno = EINVAL; return (-1); } } else { gfal_errmsg (errbuf, errbufsz, GFAL_ERRLEVEL_ERROR, "You have to define 'RMC_ENDPOINT' and 'LRC_ENDPOINT' environment variables, when BDII calls are disabled"); errno = EINVAL; return (-1); } } #ifdef GFAL_SECURE if (strncmp (rmc_endpoint, "https", 5) == 0) { flags = CGSI_OPT_SSL_COMPATIBLE; soap_register_plugin_arg (soap, client_cgsi_plugin, &flags); } #endif gfal_errmsg (errbuf, errbufsz, GFAL_ERRLEVEL_ERROR, "RMC/LRC are obsolete! Please use LFC instead."); return (0); }
CWebServiceApi::CWebServiceApi(std::string endpoint) :m_soap_endpoint(endpoint) { soap_init(&clientSOAP); setlocale(LC_ALL,"chs"); soap_set_mode(&clientSOAP,SOAP_C_MBSTRING); }
// Caller needs to free *output if non-NULL void condor_base64_decode(const char *input,unsigned char **output, int *output_length) { ASSERT( input ); ASSERT( output ); ASSERT( output_length ); int input_length = strlen(input); // safe to assume output length is <= input_length *output = (unsigned char *)malloc(input_length + 1); ASSERT( *output ); memset(*output, 0, input_length); struct soap soap; soap_init(&soap); soap_base642s(&soap,input,(char*)(*output),input_length,output_length); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); if( *output_length < 0 ) { free( *output ); *output = NULL; } }
// Caller needs to free the returned pointer char* condor_base64_encode(const unsigned char *input, int length) { char *buff = NULL; if ( length < 1 ) { buff = (char *)malloc(1); buff[0] = '\0'; return buff; } int buff_len = (length+2)/3*4+1; buff = (char *)malloc(buff_len); ASSERT(buff); memset(buff,0,buff_len); struct soap soap; soap_init(&soap); soap_s2base64(&soap,input,buff,length); soap_destroy(&soap); soap_end(&soap); soap_done(&soap); return buff; }
int main() { struct soap soap; int m, s; // master and slave sockets int i; soap_init(&soap); m = soap_bind(&soap, "127.0.0.1", 9111, 100); if (m < 0) soap_print_fault(&soap, stderr); else { fprintf(stderr, "Socket connection successful: master socket = %d\n", m); for (i = 1; ; i++) { s = soap_accept(&soap); if (s < 0) { soap_print_fault(&soap, stderr); break; } fprintf(stderr, "%d: accepted connection from IP=%d.%d.%d.%d socket=%d\n", i, (soap.ip >> 24)&0xFF, (soap.ip>>16)&0xFF, (soap.ip>>8)&0xFF, soap.ip&0xFF, s); if(soap_serve(&soap) != SOAP_OK) // process RPC request soap_print_fault(&soap, stderr); // print error fprintf(stderr,"request served\n"); soap_destroy(&soap); // clean up class instances soap_end(&soap); // clean up everything and close socket } } soap_done(&soap); // close master socket and detach environment }
int main(int argc, char **argv) { int m, s; /* master and slave sockets */ struct soap soap; soap_init(&soap); if (argc < 2) soap_serve(&soap); /* serve as CGI application */ else { m = soap_bind(&soap, NULL, atoi(argv[1]), 100); if (m < 0) { soap_print_fault(&soap, stderr); exit(-1); } fprintf(stderr, "Socket connection successful: master socket = %d\n", m); for ( ; ; ) { s = soap_accept(&soap); fprintf(stderr, "Socket connection successful: slave socket = %d\n", s); if (s < 0) { soap_print_fault(&soap, stderr); exit(-1); } soap_serve(&soap); soap_end(&soap); } } return 0; }
int main(int argc, char **argv) { int result = -1; int id_count = 1; struct Namespace namespaces[] = { // {"ns-prefix", "ns-name"} {"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope"}, // MUST be first {"d", "http://schemas.xmlsoap.org/ws/2005/04/discovery"}, {"wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing"}, {"dn", "http://www.onvif.org/ver10/network/wsdl"}, // given by the service description {NULL, NULL} // end of table }; // Get UUID uuid_t uuid; char szUuid[36] = {0}; char szMsgID[50] = {0}; uuid_generate_time(uuid); uuid_unparse(uuid, szUuid); snprintf(szMsgID, sizeof(szMsgID), "uuid:%s", szUuid); struct soap soap; struct SOAP_ENV__Header header; // the SOAP Header soap_init(&soap); soap.send_timeout = 1; // 1s timeout soap.recv_timeout = 1; // 1s timeout soap_set_namespaces(&soap, namespaces); soap_default_SOAP_ENV__Header(&soap, &header); // init SOAP Header header.wsa__MessageID = szMsgID; 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; struct d__ProbeMatchType r; // Send and receive messages over UDP: if (soap_send_d__Probe(&soap, "soap.udp://239.255.255.250:3702", NULL, "", "")) { soap_print_fault(&soap, stderr); } // Send and receive messages over UDP: if (soap_send_d__ProbeMatches(&soap, "soap.udp://239.255.255.250:3702", NULL, NULL)) { soap_print_fault(&soap, stderr); } soap_destroy(&soap); // cleanup soap_end(&soap); // cleanup soap_done(&soap); // close connection (should not use soap struct after this) return 0; }
int main(int argc, char **argv){ struct soap mySoap; char *rpDoc; char *passPtr; const int MAX_LEN = 1024; char input[MAX_LEN]; char username[MAX_LEN]; signal(SIGPIPE, sigpipe_handle); if(argc != 2){ printf("Usage:\n getResourcePropertyDoc <EPR of SWS>\n"); return 1; } snprintf(username, MAX_LEN, "%s", getenv("USER")); soap_init(&mySoap); /* If address of SWS begins with 'https' then initialize SSL context */ if( (strstr(argv[1], "https") == argv[1]) ){ /* - don't bother with mutually-authenticated SSL if( !(passPtr = getpass("Enter passphrase for key: ")) ){ printf("Failed to get passphrase from command line\n"); return 1; } strncpy(input, passPtr, MAX_LEN); */ init_ssl_context(&mySoap, REG_TRUE, NULL,/* user's cert. & key file */ NULL,/* Password to read key file */ "/etc/grid-security/certificates"); } if( !(passPtr = getpass("Enter SWS password: "******"Failed to get SWS password from command line\n"); return 1; } get_resource_property_doc(&mySoap, argv[1], username, passPtr, &rpDoc); fprintf(stdout, "\n\n%s\n\n", rpDoc); /* Explicitly wipe the passphrase from memory */ memset((void *)(input), '\0', MAX_LEN); soap_end(&mySoap); soap_done(&mySoap); return 0; }
int main(int argc, char **argv) { // initialize EMBASSY info embInitPV("kclique", argc, argv, "KBWS", "1.0.9"); struct soap soap; char* jobid; char* result; AjPFile infile; AjPFile outf; AjPStr substr; AjPStr indata = NULL; AjPStr line = NULL; infile = ajAcdGetInfile("infile"); outf = ajAcdGetOutfile("outfile"); while (ajReadline(infile, &line)) { ajStrAppendS(&indata, line); ajStrAppendC(&indata, "\n"); } soap_init(&soap); char* in0; in0 = ajCharNewS(indata); if ( soap_call_ns1__runClique( &soap, NULL, NULL, in0, &jobid ) == SOAP_OK ) { } else { soap_print_fault(&soap, stderr); } int check = 0; while ( check == 0 ) { if ( soap_call_ns1__checkStatus( &soap, NULL, NULL, jobid, &check ) == SOAP_OK ) { } else { soap_print_fault(&soap, stderr); } sleep(3); } if ( soap_call_ns1__getResult( &soap, NULL, NULL, jobid, &result ) == SOAP_OK ) { substr = ajStrNewC(result); ajFmtPrintF(outf,"%S\n",substr); } else { soap_print_fault(&soap, stderr); } soap_destroy(&soap); soap_end(&soap); soap_done(&soap); ajFileClose(&infile); ajFileClose(&outf); ajStrDel(&substr); embExit(); return 0; }
int main() { struct soap soap; soap_init(&soap); soap_set_namespaces(&soap, xmas_namespaces); return xmas_serve(&soap); }
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); }
int main() { struct soap soap; char *t; soap_init(&soap); if (soap_call_ns__LocalTimeByZipCode(&soap, "http://www.alethea.net/webservices/LocalTime.asmx", "http://www.alethea.net/webservices/LocalTimeByZipCode", "32306", &t)) soap_print_fault(&soap, stderr); else printf("Time = %s\n", t); return 0; }
int main() { struct soap soap; double a, b, result; /* Init SSL */ soap_ssl_init(); if (CRYPTO_thread_setup()) { fprintf(stderr, "Cannot setup thread mutex for OpenSSL\n"); exit(1); } a = 10.0; b = 20.0; /* Init gSOAP context */ soap_init(&soap); /* The supplied server certificate "server.pem" assumes that the server is running on 'localhost', so clients can only connect from the same host when verifying the server's certificate. Use SOAP_SSL_NO_AUTHENTICATION to omit the authentication of the server and use encryption directly from any site. To verify the certificates of third-party services, they must provide a certificate issued by Verisign or another trusted CA. At the client-side, the capath parameter should point to a directory that contains these trusted (root) certificates or the cafile parameter should refer to one file will all certificates. To help you out, the supplied "cacerts.pem" file contains the certificates issued by various CAs. You should use this file for the cafile parameter instead of "cacert.pem" to connect to trusted servers. Note that the client may fail to connect if the server's credentials have problems (e.g. expired). Use SOAP_SSL_NO_AUTHENTICATION and set cacert to NULL to encrypt messages if you don't care about the trustworthyness of the server. Note: setting capath may not work on Windows. */ if (soap_ssl_client_context(&soap, /* SOAP_SSL_NO_AUTHENTICATION, */ /* for encryption w/o authentication */ /* SOAP_SSL_DEFAULT | SOAP_SSL_SKIP_HOST_CHECK, */ /* if we don't want the host name checks since these will change from machine to machine */ SOAP_SSL_DEFAULT, /* use SOAP_SSL_DEFAULT in production code */ NULL, /* keyfile (cert+key): required only when client must authenticate to server (see SSL docs to create this file) */ NULL, /* password to read the keyfile */ "cacert.pem", /* optional cacert file to store trusted certificates, use cacerts.pem for all public certificates issued by common CAs */ NULL, /* optional capath to directory with trusted certificates */ NULL /* if randfile!=NULL: use a file with random data to seed randomness */ )) { soap_print_fault(&soap, stderr); exit(1); } soap.connect_timeout = 60; /* try to connect for 1 minute */ soap.send_timeout = soap.recv_timeout = 30; /* if I/O stalls, then timeout after 30 seconds */ if (soap_call_ns__add(&soap, server, "", a, b, &result) == SOAP_OK) fprintf(stdout, "Result: %f + %f = %f\n", a, b, result); else soap_print_fault(&soap, stderr); soap_destroy(&soap); /* C++ */ soap_end(&soap); soap_done(&soap); CRYPTO_thread_cleanup(); return 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); }
// WS_QUERY_BY_KEY (CLIENT SIDE) void audioDB::ws_query_by_key(const char*dbName, const char *trackKey, const char* featureFileName, const char* hostport){ struct soap soap; adb__queryResponse adbQueryResponse; /* JUST TRY TO USE A DATA STRUCTURE WITH PHP adb__sequenceQueryParms asqp; asqp.keyList = (char*)trackFileName; asqp.timesFileName = (char*)timesFileName; asqp.queryPoint = queryPoint; asqp.pointNN = pointNN; asqp.trackNN = trackNN; asqp.sequenceLength = sequenceLength; asqp.radius = radius; asqp.relative_threshold = relative_threshold; asqp.absolute_threshold = absolute_threshold; asqp.usingQueryPoint = usingQueryPoint; asqp.lsh_exact = lsh_exact; */ VERB_LOG(1, "Calling %s query on database %s with %s=%s\n", (trackKey&&strlen(trackKey))?"KEY":"FILENAME", dbName, (trackKey&&strlen(trackKey))?"KEY":"FILENAME",(trackKey&&strlen(trackKey))?trackKey:featureFileName); soap_init(&soap); if(queryType==O2_SEQUENCE_QUERY || queryType==O2_N_SEQUENCE_QUERY){ if(soap_call_adb__sequenceQueryByKey(&soap,hostport,NULL, (char*)dbName, (char*)trackKey, (char*)featureFileName, queryType, (char*)trackFileName, // this means keyFileName (char*)timesFileName, queryPoint, pointNN, trackNN, sequenceLength, radius, absolute_threshold, usingQueryPoint, lsh_exact, no_unit_norming, adbQueryResponse)==SOAP_OK){ //std::std::cerr << "result list length:" << adbQueryResponse.result.__sizeRlist << std::std::endl; for(int i=0; i<adbQueryResponse.result.__sizeRlist; i++) std::cout << adbQueryResponse.result.Rlist[i] << " " << adbQueryResponse.result.Dist[i] << " " << adbQueryResponse.result.Qpos[i] << " " << adbQueryResponse.result.Spos[i] << std::endl; } else { char fault[MAXSTR]; soap_sprint_fault(&soap, fault, MAXSTR); error(fault); } } else ;// FIX ME: WRITE NON-SEQUENCE QUERY BY KEY ? soap_destroy(&soap); soap_end(&soap); soap_done(&soap); }
int main(int argc, char **argv) { struct soap soap; struct ns__echoString r; soap_init(&soap); soap_register_plugin(&soap, http_md5); if (argc < 2) soap_serve(&soap); else if (soap_call_ns__echoString(&soap, "http://", NULL, argv[1], &r)) soap_print_fault(&soap, stderr); soap_end(&soap); soap_done(&soap); return 0; }
/* Server loop */ void audioDB::startServer(){ struct soap soap; int m, s; // master and slave sockets soap_init(&soap); // FIXME: largely this use of SO_REUSEADDR is to make writing (and // running) test cases more convenient, so that multiple test runs // in close succession don't fail because of a bin() error. // Investigate whether there are any potential drawbacks in this, // and also whether there's a better way to write the tests. -- // CSR, 2007-10-03 soap.bind_flags |= SO_REUSEADDR; m = soap_bind(&soap, NULL, port, 100); if (m < 0) soap_print_fault(&soap, stderr); else { fprintf(stderr, "Socket connection successful: master socket = %d\n", m); /* FIXME: we used to have a global cache of a single LSH index * here. CSR removed it because it interacted badly with * APIification of querying, replacing it with a per-open-adb * cache; we should try to take advantage of that instead. */ // Server-side path prefix to databases and features if(adb_root) SERVER_ADB_ROOT = (char*)adb_root; // Server-side database root if(adb_feature_root) SERVER_ADB_FEATURE_ROOT = (char*)adb_feature_root; // Server-side features root isServer = 1; // From this point, errors are reported via SOAP to the client for (int i = 1; ; i++) { s = soap_accept(&soap); if (s < 0) { soap_print_fault(&soap, stderr); break; } /* FIXME: find a way to play nice with logging when run from /etc/init.d scripts: at present this just goes nowhere */ fprintf(stderr, "%d: accepted connection from IP=%lu.%lu.%lu.%lu socket=%d\n", i, (soap.ip >> 24)&0xFF, (soap.ip >> 16)&0xFF, (soap.ip >> 8)&0xFF, soap.ip&0xFF, s); if (soap_serve(&soap) != SOAP_OK) // process RPC request soap_print_fault(&soap, stderr); // print error fprintf(stderr, "request served\n"); soap_destroy(&soap); // clean up class instances soap_end(&soap); // clean up everything and close socket } } soap_done(&soap); // close master socket and detach environment }
int main(int argc, char **argv) { struct soap soap; double response; if (argc < 2) { fprintf(stderr, "Usage: ip:port\n"); exit(0); } soap_init(&soap); double op1, op2; char op; printf("Entrez l'operande 1:\n"); scanf("%f", &op1); fflush(stdin); printf("Entrez l'operande 2:\n"); scanf("%f", &op2); fflush(stdin); printf("Entrez l'operateur:"); scanf(" %c", &op); fflush(stdin); printf("%c", op); switch(op) { case '+': soap_call_ns2__add(&soap, argv[1], "", op1, op2, &response); break; case '-': soap_call_ns2__sub(&soap, argv[1], "", op1, op2, &response); break; case '*': soap_call_ns2__mul(&soap, argv[1], "", op1, op2, &response); break; case '/': soap_call_ns2__div(&soap, argv[1], "", op1, op2, &response); break; default: printf("invalid operator\n"); break; } if (soap.error){ soap_print_fault(&soap, stderr); exit(1); } else { printf("resultat = %f\n", response); } soap_destroy(&soap); soap_end(&soap); soap_done(&soap); return 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); }
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); }
DSL_int32_t DSL_CPE_SoapInit(DSL_CPE_Control_Context_t *pContext) { DSL_int32_t ret = 0; memset(&SoapEnv, 0, sizeof(Soap_env_t)); soap_init(&SoapEnv.client.soap); /* Set client connection timeout (=1sec) therefore NONBLOCK mode activated.*/ SoapEnv.client.soap.connect_timeout = 1; /* DO NOT INCLUDE "SOAP_IO_KEEPALIVE" FLAG FOR CLIENT BECAUSE THIS MIGHT RESULT IN PROBLEMS!!! */ /*soap_init2(&SoapEnv.client.soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);*/ SoapEnv.client.bInit = DSL_TRUE; /*soap_init(&SoapEnv.server.soap);*/ soap_init2(&SoapEnv.server.soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE); SoapEnv.server.soap.accept_timeout = 60; /* let server time out after 60 sec of inactivity */ SoapEnv.server.soap.send_timeout = 10; /* 10 seconds */ SoapEnv.server.soap.recv_timeout = 10; /* 10 seconds */ SoapEnv.server.soap.max_keep_alive = 100; /* max keep-alive sequence (100 packets) */ SoapEnv.server.m = soap_bind ( &SoapEnv.server.soap, NULL, DSL_CPE_SOAP_PORT, 100 ); if ( SoapEnv.server.m < 0 ) { /*soap_print_fault ( &SoapEnv.server.soap, stderr );*/ DSL_CCA_DEBUG(DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX "binding SOAP port (%d) failed - already in use?" DSL_CPE_CRLF, DSL_CPE_SOAP_PORT)); return 1; } SoapEnv.bRun = DSL_TRUE; SoapEnv.pContext = pContext; memset(&SoapControl, 0x00, sizeof(SoapControl)); DSL_CPE_ThreadInit(&SoapControl, "dsl_soap", DSL_CPE_SOAP, DSL_CPE_SOAP_STACK_SIZE, DSL_CPE_PRIORITY, (DSL_uint32_t)&SoapEnv, (DSL_uint32_t)DSL_NULL); DSL_CPE_LockCreate(&SoapEnv.callBackSem); ret = DSL_CPE_CLI_Register(&SoapEnv.pSOAPCLIContext, &SoapEnv, DSL_CPE_Soap_Exit, SOAP_EventCallback); return ret; }