1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| //librairires nécessaires à SOAP
#include "soapH.h"
#include "ClientRequestBinding.nsmap"
//librairies nécessaires aux threads
#include <pthread.h>
#include <unistd.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
// pour utiliser le type string sans std::
using namespace std;
//déclaration d'un mutex
static pthread_mutex_t mutex;
void* ThreadLog(void *p_tsoap)
{
struct soap *v_soap = (struct soap*)p_tsoap;
for(;;)
{
pthread_mutex_lock(&mutex);
soap_call_ns1__ClientRequest(&v_soap , adresse.c_str() , "" , "LOG",sessionid, 0);
pthread_mutex_unlock(&mutex);
sleep(10);
}
}
int main(int argc,char *argv[]){
int m;
pthread_t thread1;
// adresse du serveur
string adresse =(string)argv[1];
//fonction correspondant a la définition WSDL
ns1__ClientRequestResponse v_response ;
struct soap v_soap;
struct soap *v_tsoap;
//initialisation de la socket
soap_init(&v_soap);
soap_set_namespaces(&v_soap, namespaces);
//gestion des timeout
v_soap.send_timeout = 10;
v_soap.recv_timeout = 10;
//appel de la fonction avec passage des arguments et retour d'une structure
soap_call_ns1__ClientRequest(&v_soap, adresse.c_str(), "",argv[2],argv[3],argv[4],v_response);
if (strcmp(argv[2],"BOOT")==0)
{
//mise ne mémoire des données en retour;
int LogTime = atoi(v_response.paramresp1.c_str()) ; //conversion char -> string -> int
string SessionId = v_response.paramresp2 ;
v_tsoap = soap_copy(&v_soap);
pthread_create(&thread1 , NULL , (void* (*) (void*)) , ThreadLog , (void*)v_tsoap );
}
if(v_soap.error)
{
soap_print_fault(&v_soap, stderr);
}
soap_end(&v_soap);
return(0); } |
Partager