Ignore:
Timestamp:
Jan 9, 2013, 11:52:44 PM (11 years ago)
Author:
djay
Message:

Fix asynchronous support on windows platform, fix storage of responseDocument and add a sample service in Python language using the ZOO-API. Update makefile.vc and nmake.opt to remove unneeded cgic linkage. Fix for headers section to display only if needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/zoo_service_loader.c

    r381 r384  
    431431}
    432432
     433
    433434#ifdef WIN32
    434435/**
     
    449450  char *dataInputsKVP=getMapsAsKVP(inputs,cgiContentLength,0);
    450451  char *dataOutputsKVP=getMapsAsKVP(outputs,cgiContentLength,1);
     452#ifdef DEBUG
    451453  fprintf(stderr,"DATAINPUTSKVP %s\n",dataInputsKVP);
    452454  fprintf(stderr,"DATAOUTPUTSKVP %s\n",dataOutputsKVP);
     455#endif
    453456  map *sid=getMapFromMaps(m,"lenv","sid");
    454457  map* r_inputs=getMapFromMaps(m,"main","tmpPath");
    455   map* r_inputs1=getMap(s1->content,"ServiceProvider");
     458  map* r_inputs1=getMap(request_inputs,"metapath");
     459  int hasIn=-1;
     460  if(r_inputs1==NULL){
     461    r_inputs1=createMap("metapath","");
     462    hasIn=1;
     463  }
    456464  map* r_inputs2=getMap(s1->content,"ResponseDocument");
    457465  if(r_inputs2==NULL)
     
    460468
    461469  if(r_inputs2!=NULL){
    462     sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value);
    463         sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP);
     470    sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,r_inputs2->value,sid->value);
     471    sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&%s=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,r_inputs2->name,dataOutputsKVP);
    464472  }
    465473  else{
    466     sprintf(tmp,"\"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",req->value,id->value,dataInputsKVP,sid->value);
    467     sprintf(tmpq,"request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",req->value,id->value,dataInputsKVP,sid->value);
    468   }
    469 
     474    sprintf(tmp,"\"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s&cgiSid=%s\"",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value);
     475    sprintf(tmpq,"metapath=%s&request=%s&service=WPS&version=1.0.0&Identifier=%s&DataInputs=%s",r_inputs1->value,req->value,id->value,dataInputsKVP,sid->value);
     476  }
     477 
     478  if(hasIn>0){
     479    freeMap(&r_inputs1);
     480    free(r_inputs1);
     481  }
    470482  char *tmp1=strdup(tmp);
    471483  sprintf(tmp,"zoo_loader.cgi %s \"%s\"",tmp1,sid->value);
    472 
     484 
    473485  free(dataInputsKVP);
    474486  free(dataOutputsKVP);
     487  //printf("REQUEST IS : %s \n",tmp);
     488#ifdef DEBUG
    475489  fprintf(stderr,"REQUEST IS : %s \n",tmp);
     490#endif
    476491  SetEnvironmentVariable("CGISID",TEXT(sid->value));
    477492  SetEnvironmentVariable("QUERY_STRING",TEXT(tmpq));
     
    492507      )
    493508    {
     509      //printf("CreateProcess failed (%d).\n",GetLastError() );
     510#ifdef DEBUG
    494511      fprintf( stderr, "CreateProcess failed (%d).\n", GetLastError() );
     512#endif
    495513      return ;
    496514    }else{
     515    //printf("CreateProcess successfull (%d).\n",GetLastError() );
     516#ifdef DEBUG
    497517    fprintf( stderr, "CreateProcess successfull (%d).\n\n\n\n", GetLastError() );
     518#endif
    498519  }
    499520  CloseHandle( pi.hProcess );
    500521  CloseHandle( pi.hThread );
     522  //printf("CreateProcess finished !\n");
     523#ifdef DEBUG
    501524  fprintf(stderr,"CreateProcess finished !\n");
     525#endif
    502526}
    503527#endif
     
    17011725        }
    17021726        /**
    1703          * Get every attribute from a LiteralData node
    1704          * storeExecuteResponse, lineage, status
     1727         * Get every attribute: storeExecuteResponse, lineage, status
    17051728         */
    17061729        const char *ress[3]={"storeExecuteResponse","lineage","status"};
     
    17421765              tmpmaps->next=NULL;
    17431766            }
    1744             else
    1745               tmpmaps->name=strdup((char*)val);;
     1767            else{
     1768              //free(tmpmaps->name);
     1769              tmpmaps->name=strdup((char*)val);
     1770            }
    17461771            xmlFree(val);
    17471772          }
     
    17641789            else{
    17651790              if(tmpmaps->content!=NULL)
    1766                 addToMap(tmpmaps->content,
    1767                          (char*)cur1->name,(char*)val);
     1791                addToMap(tmpmaps->content,(char*)cur1->name,(char*)val);
    17681792              else
    1769                 tmpmaps->content=
    1770                   createMap((char*)cur1->name,(char*)val);
     1793                tmpmaps->content=createMap((char*)cur1->name,(char*)val);
    17711794            }
    17721795            xmlFree(val);
     
    17951818            }
    17961819            xmlNodePtr cur2=cur1->children;
     1820            while(cur2!=NULL && cur2->type != XML_ELEMENT_NODE)
     1821              cur2=cur2->next;
    17971822            while(cur2){
    17981823              /**
     
    21252150  if(test1!=NULL){
    21262151    cgiSid=test1->value;
    2127   }
    2128   if(cgiSid!=NULL){
    21292152    addToMap(request_inputs,"storeExecuteResponse","true");
    21302153    addToMap(request_inputs,"status","true");
     2154    setMapInMaps(m,"lenv","sid",test1->value);
    21312155    status=getMap(request_inputs,"status");
    2132     //fprintf(stderr,"cgiSID : %s",cgiSid);
    2133   }
    2134 #endif
     2156    printf("cgiSid %s\n",cgiSid);
     2157  }
     2158#endif
     2159  int hrstd=-1;
     2160  char *fbkp,*fbkp1;
     2161  FILE *f0,*f1;
    21352162  if(status!=NULL)
    21362163    if(strcasecmp(status->value,"false")==0)
     
    21492176#else
    21502177    if(cgiSid==NULL){
    2151       addToMap(request_inputs,"cgSid",cgiSid);
    21522178      createProcess(m,request_inputs,s1,NULL,cpid,request_input_real_format,request_output_real_format);
    21532179      pid = cpid;
     
    21552181      pid=0;
    21562182      cpid=atoi(cgiSid);
    2157     }
    2158     fflush(stderr);
     2183      printf("cgiSid %s\n",cgiSid);
     2184    }
     2185    //printf("pid cpid %d %d\n",pid,cpid);
     2186    //fflush(stderr);
    21592187#endif
    21602188    if (pid > 0) {
     
    21742202      r_inputs=getMapFromMaps(m,"main","tmpPath");
    21752203      map* r_inputs1=getMap(s1->content,"ServiceProvider");
    2176       char* fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char));
     2204      fbkp=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char));
    21772205      sprintf(fbkp,"%s/%s_%d.xml",r_inputs->value,r_inputs1->value,cpid);
    2178       char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+100)*sizeof(char));
     2206      char* flog=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char));
    21792207      sprintf(flog,"%s/%s_%d_error.log",r_inputs->value,r_inputs1->value,cpid);
    21802208#ifdef DEBUG
     
    21842212#endif
    21852213      freopen(flog,"w+",stderr);
    2186       freopen(fbkp , "w+", stdout);
     2214      f0=freopen(fbkp , "w+", stdout);
    21872215      fclose(stdin);
    2188       free(fbkp);
    21892216      free(flog);
    21902217      /**
     
    21942221       * this way the data will be updated at the end of the process run.
    21952222       */
    2196       updateStatus(m);
    21972223      printProcessResponse(m,request_inputs,cpid,
    21982224                           s1,r_inputs1->value,SERVICE_STARTED,
     
    22022228      fflush(stdout);
    22032229      rewind(stdout);
    2204 #endif
    2205 
     2230#else
     2231#endif
     2232      fbkp1=(char*)malloc((strlen(r_inputs->value)+strlen(r_inputs1->value)+1024)*sizeof(char));
     2233      sprintf(fbkp1,"%s/%s_final_%d.xml",r_inputs->value,r_inputs1->value,cpid);
     2234      f1=freopen(fbkp1 , "w+", stdout);
    22062235      loadServiceAndRun(&m,s1,request_inputs,&request_input_real_format,&request_output_real_format,&eres);
    2207 
    22082236    } else {
    22092237      /**
     
    22422270    fclose(stderr);
    22432271    unhandleStatus(m);
     2272    /**
     2273     * Dump back the final file fbkp1 to fbkp
     2274     */
     2275    fclose(f0);
     2276    fclose(f1);
     2277    FILE* f2=fopen(fbkp1,"rb");
     2278    FILE* f3=fopen(fbkp,"wb+");
     2279    free(fbkp);
     2280    free(fbkp1);
     2281    fseek(f2,0,SEEK_END);
     2282    long flen=ftell(f2);
     2283    fseek(f2,0,SEEK_SET);
     2284    char *tmps1=(char*)malloc((flen+1)*sizeof(char));
     2285    fread(tmps1,flen,1,f2);
     2286    fwrite(tmps1,1,flen,f3);
     2287    fclose(f2);
     2288    fclose(f3);
    22442289  }
    22452290
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png