Service() { soap_set_mode(soap, SOAP_XML_INDENT); soap_register_plugin(soap, soap_wsa); soap_register_plugin(soap, soap_wsrm); soap->send_timeout = soap->recv_timeout = 10; // 10 sec soap_set_mode(callback.soap, SOAP_XML_INDENT); soap_register_plugin(callback.soap, soap_wsa); soap_register_plugin(callback.soap, soap_wsrm); callback.soap->send_timeout = callback.soap->recv_timeout = 10; // 10 sec result = 0.0; equation.str(""); equation << 0.0; }
OnvifClientPTZ::OnvifClientPTZ(std::string url, std::string user, std::string password, bool showCapabilities) : OnvifClientDevice(url, user, password, showCapabilities){ if(_hasPTZ){ proxyPTZ.soap_endpoint = _strUrl.c_str(); soap_register_plugin(proxyPTZ.soap, soap_wsse); }else{ throw "Camera does not implement PTZ functions"; } }
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; }
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; }
struct soap* init_soap(void) { FILE *fd = NULL; struct soap* soap = NULL; char passwd[10] = {'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0'}; soap = soap_new1(SOAP_XML_CANONICAL | SOAP_XML_INDENT); soap_ssl_init(); // soap_register_plugin(soap, plugin); // register plugin soap_register_plugin(soap, soap_wsse); fd = fopen("secrets", "r"); if (fd) { fgets(passwd, 10, fd); fclose(fd); if (passwd == NULL) { perror("Unable to read password for X509 certificate."); return NULL; } } else { perror("Unable to open secrets file"); return NULL; } fd = fopen("DMOPEN_100014_PRIVATE.pem", "r"); if (fd) { rsa_private_key = PEM_read_PrivateKey(fd, NULL, NULL, passwd); fclose(fd); if (rsa_private_key == NULL) { perror("Error reading private key"); return NULL; } } else { perror("Unable to open Private X509 .pem file"); return NULL; } fd = fopen("DMOPEN_100014.pem", "r"); if (fd) { cert = PEM_read_X509(fd, NULL, NULL, NULL); fclose(fd); if (cert == NULL) { perror("Error reading certificate file"); return NULL; } } else { perror("Unable to open publix X509 .pem file"); return NULL; } return soap; }
Client(const char *serverURI) { soap_set_mode(soap, SOAP_XML_INDENT); soap_register_plugin(soap, soap_wsa); soap_register_plugin(soap, soap_wsrm); soap_endpoint = serverURI; soap->send_timeout = soap->recv_timeout = 10; // 10 sec soap_set_mode(callback.soap, SOAP_XML_INDENT); soap_register_plugin(callback.soap, soap_wsa); soap_register_plugin(callback.soap, soap_wsrm); callback.soap->send_timeout = callback.soap->recv_timeout = 10; // 10 sec callback.soap->bind_flags = SO_REUSEADDR; // allow immediate bind if (!soap_valid_socket(callback.bind(NULL, clientPort, 100))) { callback.soap_stream_fault(std::cerr); exit(1); } #ifdef CB_THREAD THREAD_CREATE(&tid, (void*(*)(void*))callback_server, (void*)&callback); #endif }
int main(int argc, char **argv) { struct soap soap; if (argc < 2) { fprintf(stderr, "Usage: httpgettest URL\n"); exit(0); } soap_init(&soap); soap_register_plugin(&soap, http_get); // register plugin if (soap_get_connect(&soap, argv[1], NULL) || soap_begin_recv(&soap)) { soap_print_fault(&soap, stderr); exit(1); } if (soap.http_content) printf("Content type = %s\n", soap.http_content); printf("Content length = %ld\n", soap.length); if ((soap.mode & SOAP_IO) == SOAP_IO_CHUNK #ifdef WITH_ZLIB || soap.zlib_in != SOAP_ZLIB_NONE #endif ) { soap_wchar c; // This loop handles chunked/compressed transfers for (;;) { if ((c = soap_getchar(&soap)) == (int)EOF) break; putchar((int)c); } } else { // This loop handles HTTP transfers (with HTTP content length set) if (soap.length) { size_t i; for (i = soap.length; i; i--) { soap_wchar c; if ((c = soap_getchar(&soap)) == (int)EOF) { soap.error = SOAP_EOF; break; } putchar((int)c); } } } soap_end_recv(&soap); soap_end(&soap); soap_done(&soap); return 0; }
void grisu_soap_logging(gboolean state) { struct logging_data *logdata; /* retrieve data struct */ logdata = (struct logging_data *) soap_lookup_plugin(&soap, logging_id); if (!logdata) { if (soap_register_plugin(&soap, logging)) soap_print_fault(&soap, stderr); else { /* register plugin if not loaded */ printf("Loaded gsoap logging plugin...\n"); logdata = (struct logging_data *) soap_lookup_plugin(&soap, logging_id); } } /* set logging state */ if (logdata) { if (state) { /* TODO - open and write something to indicate logging on/off switches? */ /* then append rather than overwrite (for clarity) */ // logdata->inbound = stdout; // logdata->outbound = stdout; // logdata->inbound = fopen("/home/sean/prog/gdis/RECV.log", "at"); // logdata->outbound = fopen("/home/sean/prog/gdis/SENT.log", "at"); logdata->outbound = fopen(GSOAP_LOGGING_SENT, "wt"); logdata->inbound = fopen(GSOAP_LOGGING_RECV, "wt"); } else { logdata->inbound = NULL; logdata->outbound = NULL; } // process messages // size_t bytes_in = logdata->stat_recv; // size_t bytes_out = logdata->stat_sent; } else printf("Gsoap logging plugin not found.\n"); }
int run_serve(int port) { struct soap *soap = soap_new1(SOAP_XML_INDENT); int ret; if (soap_register_plugin(soap, http_da)) exit(1); if (!soap_valid_socket(soap_bind(soap, NULL, port, 100))) soap_print_fault(soap, stderr); else { fprintf(stderr, "Bind to port %d successful\n", port); soap->accept_timeout = 3600; /* let server time out after one hour */ for (;;) { SOAP_SOCKET sock = soap_accept(soap); if (!soap_valid_socket(sock)) { if (soap->errnum) soap_print_fault(soap, stderr); else { fprintf(stderr, "Server timed out\n"); break; } } fprintf(stderr, "Accepting socket %d connection from IP %d.%d.%d.%d\n", sock, (int)(soap->ip>>24)&0xFF, (int)(soap->ip>>16)&0xFF, (int)(soap->ip>>8)&0xFF, (int)soap->ip&0xFF); if (soap_serve(soap)) soap_print_fault(soap, stderr); fprintf(stderr, "Served\n\n"); soap_destroy(soap); soap_end(soap); } } ret = soap->error; soap_destroy(soap); soap_end(soap); soap_free(soap); return ret; }
int bes_init(struct bes_context **context) { struct bes_context *ctx; struct soap *soap; if (context == NULL) { return BESE_BAD_ARG; } ctx = (struct bes_context *)malloc(sizeof(struct bes_context)); if (ctx == NULL) { // fprintf (stderr, "err 1\n"); return BESE_SYS_ERR; } memset(ctx, 0, sizeof(struct bes_context)); soap_ssl_init(); soap = soap_new1(SOAP_C_UTFSTRING); if (soap == NULL) { free(ctx); // fprintf (stderr, "err 2\n"); return BESE_SYS_ERR; } soap_set_recv_logfile(soap, NULL); soap_set_sent_logfile(soap, NULL); soap_set_test_logfile(soap, NULL); soap_register_plugin(soap, soap_wsse); soap_set_namespaces(soap, default_namespaces); soap_header(soap); ctx->soap = soap; *context = ctx; return BESE_OK; }
int main(int argc, char * const argv[]) { struct soap soap, soap_comm; struct _jpelem__QueryJobs qj; char *server, *example_file, *query_file, *test_file; const char *prog_name; int retval, opt, example_fd, query_fd, test_fd; format_t format = FORMAT_XML; prog_name = server = NULL; example_file = query_file = test_file = NULL; query_fd = example_fd = test_fd = -1; retval = 1; soap_init(&soap); soap_set_namespaces(&soap, jp__namespaces); /* * Soap with registered plugin can't be used for reading XML. * For communications with JP IS glite_gsplugin needs to be registered yet. */ soap_init(&soap_comm); soap_set_namespaces(&soap_comm, jp__namespaces); soap_register_plugin(&soap_comm, glite_gsplugin); /* program name */ prog_name = strrchr(argv[0], '/'); if (prog_name) prog_name++; else prog_name = argv[0]; if (argc <= 1) { usage(prog_name); goto cleanup; } /* handle arguments */ while ((opt = getopt_long(argc, argv, get_opt_string, opts, NULL)) != EOF) switch (opt) { case 'i': free(server); server = strdup(optarg); break; case 'e': free(example_file); example_file = strdup(optarg); break; case 'q': free(query_file); query_file = strdup(optarg); break; case 't': free(test_file); test_file = strdup(optarg); break; case 'f': if (strcasecmp(optarg, "xml") == 0) format = FORMAT_XML; else if (strcasecmp(optarg, "strippedxml") == 0) format = FORMAT_STRIPPEDXML; else format = FORMAT_HR; break; default: usage(prog_name); goto cleanup; } if (optind < argc) { usage(prog_name); goto cleanup; } if (!server) server = strdup(DEFAULT_JPIS); #ifdef SOAP_XML_INDENT if (format != FORMAT_STRIPPEDXML) soap_omode(&soap, SOAP_XML_INDENT); #endif /* prepare steps according to the arguments */ if (query_file) { if (strcmp(query_file, "-") == 0) query_fd = STDIN_FILENO; else if ((query_fd = open(query_file, 0)) < 0) { fprintf(stderr, "error opening %s: %s\n", query_file, strerror(errno)); goto cleanup; } free(query_file); query_file = NULL; } if (example_file) { if (strcmp(example_file, "-") == 0) example_fd = STDOUT_FILENO; else if ((example_fd = creat(example_file, S_IREAD | S_IWRITE | S_IRGRP)) < 0) { fprintf(stderr, "error creating %s: %s\n", example_file, strerror(errno)); goto cleanup; } free(example_file); example_file = NULL; } if (test_file) { if (strcmp(test_file, "-") == 0) test_fd = STDIN_FILENO; else if ((test_fd = open(test_file, 0)) < 0) { fprintf(stderr, "error opening %s: %s\n", test_file, strerror(errno)); goto cleanup; } free(test_file); test_file = NULL; } /* the dump action */ if (example_fd >= 0) { if (query_example_dump(&soap, example_fd) != 0) { fprintf(stderr, "Error dumping example query XML.\n"); } } /* the test XML file action */ if (test_fd >= 0) { soap_begin(&soap); if (query_recv(&soap, test_fd, &qj) != 0) { fprintf(stderr, "test: Error getting query XML\n"); } else { query_format(&soap, format, stdout, &qj); } soap_end(&soap); } /* query action */ if (query_fd >= 0) { struct _jpelem__QueryJobs in; struct _jpelem__QueryJobsResponse out; int ret; soap_begin(&soap); memset(&in, 0, sizeof(in)); memset(&out, 0, sizeof(out)); /* * Right way would be copy data from client query structure to IS query * structure. Just ugly retype to client here. */ if (query_recv(&soap, query_fd, (struct _jpelem__QueryJobs *)&in) != 0) { fprintf(stderr, "query: Error getting query XML\n"); } else { fprintf(stderr, "query: using JPIS %s\n\n", server); query_print(stderr, &in); fprintf(stderr, "\n"); soap_begin(&soap_comm); ret = check_fault(&soap_comm, soap_call___jpsrv__QueryJobs(&soap_comm, server, "", &in, &out)); if (ret == 0) { queryresult_format(&soap, format, stdout, (struct _jpelem__QueryJobsResponse *)&out); } else { soap_end(&soap_comm); soap_end(&soap); goto cleanup; } soap_end(&soap_comm); } soap_end(&soap); } retval = 0; cleanup: soap_done(&soap); soap_done(&soap_comm); if (example_fd > STDERR_FILENO) close(example_fd); if (query_fd > STDERR_FILENO) close(query_fd); if (test_fd > STDERR_FILENO) close(test_fd); free(server); free(example_file); free(query_file); free(test_file); return retval; }
int llamar_servicio_get(char *proxyHost) { struct value resJSON; struct soap *soap = soap_new(); soap_register_plugin(soap, http_get); if (proxyHost && strlen(proxyHost) > 0) soap->proxy_host = proxyHost; printf("Ejemplo de llamada get recuperando JSON\n"); printf("---------------------------------------\n"); if (soap_get_connect(soap, "http://jsonplaceholder.typicode.com/posts/1", NULL)) { soap_print_fault(soap, stderr); printf("Error en la conexión con la API get.\n"); goto finalizar; } if (soap_begin_recv(soap)) { soap_print_fault(soap, stderr); printf("Error en la llamada a la API get.\n"); goto finalizar; } if (json_recv(soap, &resJSON)) { soap_print_fault(soap, stderr); printf("Error en la obtención del JSON en la API get.\n"); goto finalizar; } if (soap_end_recv(soap)) { soap_print_fault(soap, stderr); printf("Error en la finalización de la API get.\n"); goto finalizar; } if (resJSON.__type == SOAP_TYPE__struct) { struct _struct *estructuraJSON; estructuraJSON = (struct _struct *)resJSON.ref; int i; for (i=0; i < estructuraJSON->__size; i++) { printf("%s: ", (estructuraJSON->member + i)->name); if ((estructuraJSON->member + i)->value.__type == SOAP_TYPE__string) { printf("%s\n", (estructuraJSON->member + i)->value.ref); } else if ((estructuraJSON->member + i)->value.__type == SOAP_TYPE__int) { printf("%ld\n", (estructuraJSON->member + i)->value.ref); } } } else { printf("Se recibe un JSON no esperado.\n"); goto finalizar; } printf("Ha finalizado correctamente la llamada get\n"); printf("------------------------------------------\n"); finalizar: soap_destroy(soap); soap_end(soap); soap_free(soap); return 0; }
int main(int argc, char **argv) { struct soap *soap = soap_new1(SOAP_XML_INDENT); soap_register_plugin(soap, soap_wsa); if (argc < 2) { /* no args: act as CGI service over stdin/out */ if (soap_serve(soap)) { soap_print_fault(soap, stderr); soap_print_fault_location(soap, stderr); } } else { int port = atoi(argv[1]); if (port) { /* stand-alone server serving messages over port */ soap->bind_flags = SO_REUSEADDR; if (!soap_valid_socket(soap_bind(soap, NULL, port, 100))) { soap_print_fault(soap, stderr); exit(1); } printf("Server is running\n"); while (soap_valid_socket(soap_accept(soap))) { if (soap_serve(soap)) { soap_print_fault(soap, stderr); soap_print_fault_location(soap, stderr); } printf("Request served\n"); soap_destroy(soap); soap_end(soap); } } else { /* client */ struct ns__wsademoResult res; soap_wsa_request(soap, RequestMessageID, ToAddress, RequestAction); if (argc >= 3) { if (strchr(argv[2], 'f')) soap_wsa_add_From(soap, FromAddress); if (strchr(argv[2], 'r')) soap_wsa_add_ReplyTo(soap, ReplyToAddress); if (strchr(argv[2], 'n')) { #ifdef SOAP_WSA_2005 soap_wsa_add_NoReply(soap); #else printf("'NoReply' feature not available with WS-Addressing 2003/2004\n"); #endif } if (strchr(argv[2], 'e')) soap_wsa_add_FaultTo(soap, FaultToAddress); } if (soap_call_ns__wsademo(soap, ToAddress, NULL, argv[1], &res)) { #ifdef SOAP_WSA_2005 wsa5__FaultCodesType fault; const char *info; if (soap->error == 202) /* HTTP ACCEPTED */ printf("Request was accepted\n"); else if (soap_wsa_check_fault(soap, &fault, &info)) { switch (fault) { case wsa5__EndpointUnavailable: fprintf(stderr, "Server %s is currently not available.\n", info?info:""); break; default: fprintf(stderr, "A wsa fault %d occurred:\n", (int)fault); soap_print_fault(soap, stderr); break; } } else soap_print_fault(soap, stderr); #else if (soap->error == 202) /* HTTP ACCEPTED */ printf("Request was accepted\n"); else soap_print_fault(soap, stderr); #endif } else if (res.out) printf("Result = %s\n", res.out); } } soap_destroy(soap); soap_end(soap); soap_done(soap); free(soap); return 0; }
int main(int argc, char **argv) { struct soap soap; int rc; unsigned short int port = PLUGIN_DEFAULT_PORT; char *server = PLUGIN_DEFAULT_HOSTNAME, *query = PLUGIN_DEFAULT_QUERY; char connection[128]; int c, result = 1; static char *USAGE = "\nUSAGE:\noph_client -s hostname -p port- q query -v\n"; fprintf(stdout, "%s", OPH_VERSION); fprintf(stdout, "%s", OPH_DISCLAIMER2); while ((c = getopt(argc, argv, "s:p:q:vxz")) != -1) { switch (c) { case 's': server = optarg; break; case 'p': port = (unsigned short int) atoi(optarg); break; case 'q': query = optarg; break; case 'v': fprintf(stdout, "%s", OPH_VERSION); exit(0); case 'x': fprintf(stdout, "%s", OPH_WARRANTY); exit(0); case 'z': fprintf(stdout, "%s", OPH_CONDITIONS); exit(0); default: fprintf(stderr, "\n%s\n", USAGE); exit(1); } } snprintf(connection, 128, "%s://%s:%d", OPH_DEFAULT_PROTOCOL, server, port); globus_module_activate(GLOBUS_GSI_GSSAPI_MODULE); soap_init(&soap); /* now we register the GSI plugin */ if (soap_register_plugin(&soap, globus_gsi)) { soap_print_fault(&soap, stderr); /* deallocate gsoap run-time environment */ soap_destroy(&soap); soap_end(&soap); soap_done(&soap); /* deactivate globus module */ globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE); exit(EXIT_FAILURE); } /* setup of authorization and credential renewal callbacks */ gsi_authorization_callback_register(&soap, gsi_authorization_callback); gsi_credential_renew_callback_register(&soap, gsi_plugin_credential_renew_callback); /* we begin acquiring our credential */ rc = gsi_acquire_credential(&soap); if (rc < 0) { /* deallocate gsoap run-time environment */ soap_destroy(&soap); soap_end(&soap); soap_done(&soap); /* deactivate globus module */ globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE); exit(EXIT_FAILURE); } /* setup of GSI channel */ gsi_set_replay(&soap, GLOBUS_TRUE); gsi_set_sequence(&soap, GLOBUS_TRUE); gsi_set_confidentiality(&soap, GLOBUS_TRUE); gsi_set_integrity(&soap, GLOBUS_TRUE); /* Timeout after 2 minutes stall on send/recv */ gsi_set_recv_timeout(&soap, 120); gsi_set_send_timeout(&soap, 120); soap.userid = NULL; soap.passwd = NULL; struct oph__ophResponse response; if (soap_call_oph__ophExecuteMain(&soap, connection, "", query, &response) == SOAP_OK) { printf("Return: %d\nJobID: %s\nResponse: %s\n", (int) response.error, response.error || !response.jobid ? "" : response.jobid, response.error || !response.response ? "" : response.response); result = response.error; } else soap_print_fault(&soap, stderr); /* deallocate gsoap run-time environment */ soap_destroy(&soap); soap_end(&soap); soap_done(&soap); /* deactivate globus module */ globus_module_deactivate(GLOBUS_GSI_GSSAPI_MODULE); return result; }
int main(int argc, char *argv[]) { SOAP_SOCKET m; #if defined(_POSIX_THREADS) || defined(_SC_THREADS) pthread_t tid; pthread_mutex_init(&global_flag, NULL); pthread_mutex_init(&libssh2_flag, NULL); pthread_cond_init(&termination_flag, NULL); #endif struct soap soap, *tsoap = NULL; psoap = &soap; int ch, msglevel = LOG_INFO; static char *USAGE = "\nUSAGE:\noph_server [-d] [-l <log_file>] [-p <port>] [-v] [-w]\n"; fprintf(stdout, "%s", OPH_VERSION); fprintf(stdout, "%s", OPH_DISCLAIMER); set_debug_level(msglevel + 10); while ((ch = getopt(argc, argv, "dhl:p:vwxz")) != -1) { switch (ch) { case 'd': msglevel = LOG_DEBUG; break; case 'h': fprintf(stdout, "%s", USAGE); return 0; case 'l': oph_log_file_name = optarg; break; case 'p': oph_server_port = optarg; break; case 'v': return 0; break; case 'w': if (msglevel < LOG_WARNING) msglevel = LOG_WARNING; break; case 'x': fprintf(stdout, "%s", OPH_WARRANTY); return 0; case 'z': fprintf(stdout, "%s", OPH_CONDITIONS); return 0; default: fprintf(stdout, "%s", USAGE); return 0; } } set_debug_level(msglevel + 10); pmesg(LOG_INFO, __FILE__, __LINE__, "Selected log level %d\n", msglevel); #ifdef OPH_SERVER_LOCATION oph_server_location = strdup(OPH_SERVER_LOCATION); #else oph_server_location = getenv(OPH_SERVER_LOCATION_STR); if (!oph_server_location) { fprintf(stderr, "OPH_SERVER_LOCATION has to be set\n"); return 1; } #endif pmesg(LOG_DEBUG, __FILE__, __LINE__, "Server location '%s'\n", oph_server_location); char configuration_file[OPH_MAX_STRING_SIZE]; snprintf(configuration_file, OPH_MAX_STRING_SIZE, OPH_CONFIGURATION_FILE, oph_server_location); set_global_values(configuration_file); if (oph_log_file_name) { if (logfile) fclose(logfile); if (!(logfile = fopen(oph_log_file_name, "a"))) { fprintf(stderr, "Wrong log file name '%s'\n", oph_log_file_name); return 1; } pmesg(LOG_INFO, __FILE__, __LINE__, "Selected log file '%s'\n", oph_log_file_name); if (logfile) set_log_file(logfile); } else oph_log_file_name = hashtbl_get(oph_server_params, OPH_SERVER_CONF_LOGFILE); int int_port = strtol(oph_server_port, NULL, 10); if (oph_handle_signals()) { pmesg(LOG_ERROR, __FILE__, __LINE__, "A problem occurred while setting up signal dispositions\n"); exit(1); } if (mysql_library_init(0, 0, 0)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Cannot setup MySQL\n"); exit(1); } oph_tp_start_xml_parser(); if (CRYPTO_thread_setup()) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Cannot setup thread mutex for OpenSSL\n"); exit(1); } soap_init(&soap); soap.fget = oph_http_get; if (soap_register_plugin(&soap, oph_plugin)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Cannot register %s plugin\n", OPH_PLUGIN_ID); soap_print_fault(&soap, stderr); cleanup(); exit(-1); } // Register serverid struct oph_plugin_data *state = NULL; if (!(state = (struct oph_plugin_data *) soap_lookup_plugin(&soap, OPH_PLUGIN_ID))) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Error on lookup plugin struct\n"); soap_print_fault(&soap, stderr); cleanup(); exit(-1); } state->serverid = strdup(oph_web_server); #ifdef WITH_OPENSSL /* init gsoap context and SSL */ if (soap_ssl_server_context(&soap, SOAP_TLSv1_2, oph_server_cert, oph_server_password, oph_server_ca, NULL, NULL, NULL, NULL)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "SSL Server Context Error\n"); soap_print_fault(&soap, stderr); cleanup(); exit(1); } #endif soap.accept_timeout = oph_server_inactivity_timeout; soap.send_timeout = soap.recv_timeout = oph_server_timeout; soap.bind_flags |= SO_REUSEADDR; m = soap_bind(&soap, NULL, int_port, 100); if (!soap_valid_socket(m)) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Soap invalid socket\n"); soap_print_fault(&soap, stderr); cleanup(); exit(1); } pmesg(LOG_DEBUG, __FILE__, __LINE__, "Bind successful: socket = %d\n", m); for (;;) { SOAP_SOCKET s = soap_accept(&soap); if (!soap_valid_socket(s)) { if (soap.errnum) { pmesg(LOG_ERROR, __FILE__, __LINE__, "Soap invalid socket\n"); soap_print_fault(&soap, stderr); } else pmesg(LOG_ERROR, __FILE__, __LINE__, "Server timed out (timeout set to %d seconds)\n", soap.accept_timeout); break; } tsoap = soap_copy(&soap); if (!tsoap) { soap_closesock(&soap); continue; } #if defined(_POSIX_THREADS) || defined(_SC_THREADS) pthread_create(&tid, NULL, (void *(*)(void *)) &process_request, tsoap); #else process_request(tsoap); #endif } cleanup(); return 0; }