Ignore:
Timestamp:
Jul 26, 2011, 5:37:58 PM (13 years ago)
Author:
djay
Message:

Base of SOAP Envelope support. Primitive cache system. Solving bugs #45, #46, #47, #48, #50

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-kernel/zoo_loader.c

    r216 r280  
    4848}
    4949
     50#include "service_internal.h"
     51
    5052xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*);
    5153int runRequest(map*);
     
    8587#ifdef DEBUG
    8688  fprintf (stderr, "Addr:%s\n", cgiRemoteAddr);
    87   fprintf (stderr, "RequestMethod:%s\n", cgiRequestMethod);
     89  fprintf (stderr, "RequestMethod: (%s) %d %d\n", cgiRequestMethod,strncasecmp(cgiRequestMethod,"post",4),strncmp(cgiContentType,"text/xml",8)==0 || strncasecmp(cgiRequestMethod,"post",4)==0);
    8890  fprintf (stderr, "Request: %s\n", cgiQueryString);
    8991#endif
     
    9395  if(strncmp(cgiContentType,"text/xml",8)==0 ||
    9496     strncasecmp(cgiRequestMethod,"post",4)==0){
    95     char *buffer=new char[cgiContentLength+1];
    96     if(fread(buffer,1,cgiContentLength,cgiIn)){
    97       buffer[cgiContentLength]=0;
    98       tmpMap=createMap("request",buffer);
     97    if(cgiContentLength==NULL){
     98       cgiContentLength=0;
     99       char *buffer=new char[2];
     100       char *res=NULL;
     101       int r=0;
     102       while(r=fread(buffer,sizeof(char),1,cgiIn)){
     103         cgiContentLength+=r;
     104         if(res==NULL){
     105           res=(char*)malloc(1*sizeof(char));
     106           sprintf(res,"%s",buffer);
     107         }
     108         else{
     109           res=(char*)realloc(res,(cgiContentLength+1)*sizeof(char));
     110           char *tmp=strdup(res);
     111           sprintf(res,"%s%s",tmp,buffer);
     112           free(tmp);
     113         }
     114       }
     115       tmpMap=createMap("request",res);
    99116    }else{
    100       char **array, **arrayStep;
    101       if (cgiFormEntries(&array) != cgiFormSuccess) {
    102         return 1;
     117      char *buffer=new char[cgiContentLength+1];
     118      if(fread(buffer,sizeof(char),cgiContentLength,cgiIn)){
     119        buffer[cgiContentLength]=0;
     120        tmpMap=createMap("request",buffer);
     121        dumpMap(tmpMap);
     122      }else{
     123        buffer[0]=0;
     124        char **array, **arrayStep;
     125        if (cgiFormEntries(&array) != cgiFormSuccess) {
     126          return 1;
     127        }
     128        arrayStep = array;
     129        while (*arrayStep) {
     130          char *ivalue=new char[cgiContentLength];
     131          cgiFormStringNoNewlines(*arrayStep, ivalue, cgiContentLength);
     132          char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(ivalue)+1)*sizeof(char));
     133          sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
     134          if(strlen(buffer)==0){
     135            sprintf(buffer,"%s",tmpValueFinal);
     136          }else{
     137            char *tmp=strdup(buffer);
     138            sprintf(buffer,"%s&%s",tmp,tmpValueFinal);
     139            free(tmp);
     140          }
     141         
     142          sprintf(tmpValueFinal,"%s=%s",*arrayStep,ivalue);
     143          free(tmpValueFinal);
     144#ifdef DEBUG
     145          fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,ivalue);
     146#endif
     147          delete[]ivalue;
     148          arrayStep++;
     149        }
     150        tmpMap=createMap("request",buffer);
    103151      }
    104       arrayStep = array;
    105       while (*arrayStep) {
    106         char *value=new char[cgiContentLength];
    107         cgiFormStringNoNewlines(*arrayStep, value, cgiContentLength);
    108         char* tmpValueFinal=(char*) malloc((strlen(*arrayStep)+strlen(value)+1)*sizeof(char));
    109         sprintf(tmpValueFinal,"%s=%s",*arrayStep,value);
    110         tmpMap=createMap("request",tmpValueFinal);
    111         free(tmpValueFinal);
    112 #ifdef DEBUG
    113         fprintf(stderr,"(( \n %s \n %s \n ))",*arrayStep,value);
    114 #endif
    115         delete[]value;
    116         arrayStep++;
    117       }
     152      delete[]buffer;
    118153    }
    119     delete[]buffer;
    120154  }
    121155  else{
     
    162196      xmlInitParser();
    163197      xmlDocPtr doc = xmlParseMemory(t1->value,cgiContentLength);
     198
     199
     200      {
     201        xmlXPathObjectPtr reqptr=extractFromDoc(doc,"/*[local-name()='Envelope']/*[local-name()='Body']/*");
     202        if(reqptr!=NULL){
     203          xmlNodeSet* req=reqptr->nodesetval;
     204          if(req!=NULL && req->nodeNr==1){
     205            addToMap(tmpMap,"soap","true");
     206            int k=0;
     207            for(k;k < req->nodeNr;k++){
     208              xmlNsPtr ns=xmlNewNs(req->nodeTab[k],BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi");
     209              xmlDocSetRootElement(doc, req->nodeTab[k]);
     210              xmlChar *xmlbuff;
     211              int buffersize;
     212              xmlDocDumpFormatMemoryEnc(doc, &xmlbuff, &buffersize, "utf-8", 1);
     213              addToMap(tmpMap,"xrequest",(char*)xmlbuff);
     214              char *tmp=(char*)xmlbuff;
     215              fprintf(stderr,"%s\n",tmp);
     216              xmlFree(xmlbuff);
     217            }
     218          }
     219        }
     220      }
     221
    164222      xmlNodePtr cur = xmlDocGetRootElement(doc);
    165223      char *tval;
     
    172230      if(tval!=NULL)
    173231        addToMap(tmpMap,"language",tval);
    174      
    175       const char* requests[3];
    176       requests[0]="GetCapabilities";
    177       requests[1]="DescribeProcess";
    178       requests[2]="Execute";
     232      const char* requests[3]={"GetCapabilities","DescribeProcess","Execute"};
    179233      for(int j=0;j<3;j++){
    180         char tt[35];
     234        char tt[128];
    181235        sprintf(tt,"/*[local-name()='%s']",requests[j]);
    182236        xmlXPathObjectPtr reqptr=extractFromDoc(doc,tt);
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