Philipp: Problem mit xmlhttpRequest:

Beitrag lesen

Hi

Ansonsten: Kannst du das Ganze nicht einmal online stellen?

Klar kann ich mal mein CGI online stellen, es kommunziert halt mit einer API.

static unsigned long size;

char *getdata()
{

char *puffer = NULL;
   char *request = getenv("REQUEST_METHOD");
   char *cont_len;
//   char *cgi_string;

/* Zuerst die Request-Methode überprüfen */
   if(  NULL == request )
      return NULL;
   /*
   else if( strcmp(request, "GET") == 0 )
      {
         Die Methode GET -> Query String abholen
         cgi_string = getenv("QUERY_STRING");
         if( NULL == cgi_string )
            return NULL;
         else
            {
               puffer =(char *) strdup(cgi_string);
               return puffer;
            }
      }
   */
   else if( strcmp(request, "POST") == 0 )
      {
         /* Die Methode POST -> Länge des Strings
            ermitteln (CONTENT_LENGTH) */
         cont_len = getenv("CONTENT_LENGTH");

if( NULL == cont_len)
            return NULL;
         else
            {
               /* String CONTENT_LENGTH in
                  unsigned long umwandeln */
               size = (unsigned long) atoi(cont_len);
               if(size <= 0)
                  return NULL; /* Keine Eingabe!?!? */
            }
         /* Jetzt lesen wir die Daten von stdin ein */
         puffer =(char *) malloc(size+1);
         if( NULL == puffer )
            return NULL;
         else
            {
               if( NULL == fgets(puffer, size+1, stdin) )
                  {
                     free(puffer);
                     return NULL;
                  }
               else  /* Rückgabewerte an den Ausrufer */
                  return puffer;
            }
      }
   else /* Weder GET-Methode noch die POST-Methode
           wurden verwendet */
      return NULL;
}

void main() {

FILE *fp;

char *buff = NULL;
  unsigned int buffsize = 0;

char* buffout=NULL;
  char* xmlresponse=NULL;

unsigned int buffoutsize = 1000;

int r = RL_API_STATUS(rl_api_initialise());

if (r == 0) {
     buff = getdata();
     //printf("Content-type: text/html\n\n Connection established %s",buff);
  }

buffsize = (unsigned int) (size);

int s = RL_API_STATUS(rl_api_execute(buff,buffsize,(char**)(&buffout),&buffoutsize));

xmlresponse =(char *) malloc(buffoutsize);

strncpy (xmlresponse,buffout,buffoutsize);
  xmlresponse[buffoutsize] = '\0';

//printf("Content-type: text/html\n\n Connection Established: %i Execute Command: %i XML Request: %s", r, s, xmlresponse);
  printf("Content-type: text/xml\n\n %s", xmlresponse);

fp = fopen("log.txt", "w");
  fprintf(fp,"Connection Established: %d\nExecution Status: %d\n",r,s);
  fprintf(fp,"BufferIn: %s\nBufferInSize: %d\n", buff, buffsize);
  fprintf(fp,"BufferOut: %s\nBufferOutSize: %d\n", buffout, buffoutsize);
  //fprintf(fp,"XMLResponseOut: %s\n", xmlresponse);
  fclose(fp);
}

LOG FILE welches geschrieben wird:

Connection Established: 0
Execution Status: 0
BufferIn: <?xml version="1.0" encoding="UTF-8"?><rl_api_cmd>get_information</rl_api_cmd>
BufferInSize: 78
BufferOut: <?xml version="1.0"?><api_information><api_version>R2004_01_28.5071</api_version><engine_version>2.10.5119</engine_version></api_information>
BufferOutSize: 141

BufferOutsize beinhalted hier die groesse(Laenge) von der XML Response.

Hoffe jemand hat nen kleinen Tip fuer mich!

Gruss
Philipp