Changeset 280
- Timestamp:
- Jul 26, 2011, 5:37:58 PM (13 years ago)
- Location:
- trunk/zoo-kernel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal.c
r279 r280 371 371 #endif 372 372 int currId=-1; 373 int currNode=-1; 373 374 if(nbNs==0){ 374 375 nbNs++; … … 403 404 } 404 405 nbNs=0; 406 } 407 408 xmlNodePtr soapEnvelope(maps* conf,xmlNodePtr n){ 409 map* soap=getMapFromMaps(conf,"main","isSoap"); 410 if(soap!=NULL && strcasecmp(soap->value,"true")==0){ 411 int lNbNs=nbNs; 412 nsName[lNbNs]=strdup("soap"); 413 usedNs[lNbNs]=xmlNewNs(NULL,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap"); 414 nbNs++; 415 xmlNodePtr nr = xmlNewNode(usedNs[lNbNs], BAD_CAST "Envelope"); 416 nsName[nbNs]=strdup("soap"); 417 usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2003/05/soap-envelope",BAD_CAST "soap"); 418 nbNs++; 419 nsName[nbNs]=strdup("xsi"); 420 usedNs[nbNs]=xmlNewNs(nr,BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",BAD_CAST "xsi"); 421 nbNs++; 422 xmlNsPtr ns_xsi=usedNs[nbNs-1]; 423 xmlNewNsProp(nr,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope"); 424 xmlNodePtr nr1 = xmlNewNode(usedNs[lNbNs], BAD_CAST "Body"); 425 xmlAddChild(nr1,n); 426 xmlAddChild(nr,nr1); 427 return nr; 428 }else 429 return n; 405 430 } 406 431 … … 719 744 xmlAddChild(n,nc1); 720 745 721 xmlDocSetRootElement(doc, n); 746 xmlNodePtr fn=soapEnvelope(m,n); 747 xmlDocSetRootElement(doc, fn); 722 748 //xmlFreeNs(ns); 723 749 free(SERVICE_URL); … … 779 805 addLangAttr(n,m); 780 806 781 xmlDocSetRootElement(doc, n); 807 xmlNodePtr fn=soapEnvelope(m,n); 808 xmlDocSetRootElement(doc, fn); 782 809 783 810 return n; … … 1007 1034 } 1008 1035 } 1036 1009 1037 _tmp=e->supported; 1038 if(_tmp==NULL && datatype==0) 1039 _tmp=e->defaults; 1040 1010 1041 int hasSupported=-1; 1011 1042 while(_tmp!=NULL){ … … 1097 1128 1098 1129 void printProcessResponse(maps* m,map* request, int pid,service* serv,const char* service,int status,maps* inputs,maps* outputs){ 1099 xmlNsPtr ns,ns _ows,ns_xlink,ns_xsi;1130 xmlNsPtr ns,ns1,ns_ows,ns_xlink,ns_xsi; 1100 1131 xmlNodePtr nr,n,nc,nc1,nc2,nc3,pseudor; 1101 1132 xmlDocPtr doc; … … 1104 1135 time_t time1; 1105 1136 time(&time1); 1137 nr=NULL; 1106 1138 /** 1107 1139 * Create the document and its temporary root. … … 1110 1142 int wpsId=zooXmlAddNs(NULL,"http://www.opengis.net/wps/1.0.0","wps"); 1111 1143 ns=usedNs[wpsId]; 1112 1144 1113 1145 n = xmlNewNode(ns, BAD_CAST "ExecuteResponse"); 1146 xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps"); 1114 1147 int owsId=zooXmlAddNs(n,"http://www.opengis.net/ows/1.1","ows"); 1115 1148 ns_ows=usedNs[owsId]; … … 1118 1151 int xsiId=zooXmlAddNs(n,"http://www.w3.org/2001/XMLSchema-instance","xsi"); 1119 1152 ns_xsi=usedNs[xsiId]; 1120 xmlNewNs(n,BAD_CAST "http://www.opengis.net/wps/1.0.0",BAD_CAST "wps"); 1121 1153 1122 1154 xmlNewNsProp(n,ns_xsi,BAD_CAST "schemaLocation",BAD_CAST "http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsExecute_response.xsd"); 1123 1155 … … 1163 1195 sprintf(currentSid,"%s",tmp_lenv->value); 1164 1196 if(tmpm==NULL || strcasecmp(tmpm->value,"false")==0){ 1165 sprintf(url,"%s /?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid);1197 sprintf(url,"%s?request=Execute&service=WPS&version=1.0.0&Identifier=GetStatus&DataInputs=sid=%s&RawDataOutput=Result",tmpm1->value,currentSid); 1166 1198 }else{ 1167 1199 if(strlen(tmpm->value)>0) … … 1180 1212 } 1181 1213 if(tmpm1!=NULL) 1182 sprintf(tmp,"%s /",tmpm1->value);1214 sprintf(tmp,"%s",tmpm1->value); 1183 1215 tmpm1=getMapFromMaps(m,"main","TmpPath"); 1184 1216 sprintf(stored_path,"%s/%s_%i.xml",tmpm1->value,service,pid); … … 1316 1348 while(mcursor!=NULL){ 1317 1349 scursor=getElements(serv->outputs,mcursor->name); 1318 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1350 if(scursor!=NULL){ 1351 printIOType(doc,nc,ns,ns_ows,ns_xlink,scursor,mcursor,"Output"); 1352 } 1319 1353 mcursor=mcursor->next; 1320 1354 } … … 1324 1358 fprintf(stderr,"printProcessResponse 1 202\n"); 1325 1359 #endif 1326 xmlDocSetRootElement(doc, n); 1360 nr=soapEnvelope(m,n); 1361 xmlDocSetRootElement(doc, nr); 1362 1327 1363 if(hasStoredExecuteResponse==true){ 1328 1364 /* We need to write the ExecuteResponse Document somewhere */ … … 1537 1573 char tmp1[1024]; 1538 1574 sprintf(tmp1,"%d",strlen(toto->value)); 1539 rs=createMap(" z",tmp1);1575 rs=createMap("size",tmp1); 1540 1576 isSized=false; 1541 1577 } … … 1547 1583 } 1548 1584 } 1549 else if(tmp !=NULL){1550 if(strncmp(tmp ->value,"text/js",4)==0 ||1551 strncmp(tmp ->value,"application/js",14)==0)1585 else if(tmp2!=NULL){ 1586 if(strncmp(tmp2->value,"text/js",7)==0 || 1587 strncmp(tmp2->value,"application/json",16)==0) 1552 1588 xmlAddChild(nc3,xmlNewCDataBlock(doc,BAD_CAST toto->value,strlen(toto->value))); 1553 else 1554 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1589 else{ 1590 if(strncmp(tmp2->value,"text/xml",8)==0 || 1591 strncmp(tmp2->value,"application/vnd.google-earth.kml",32)!=0){ 1592 xmlDocPtr doc = 1593 xmlParseMemory(BAD_CAST toto->value,strlen(BAD_CAST toto->value)); 1594 xmlNodePtr ir = xmlDocGetRootElement(doc); 1595 xmlAddChild(nc3,ir); 1596 } 1597 else 1598 xmlAddChild(nc3,xmlNewText(BAD_CAST toto->value)); 1599 } 1555 1600 xmlAddChild(nc2,nc3); 1556 1601 } … … 1961 2006 elements* tmpInputs=in; 1962 2007 maps* out1=*out; 2008 if(type==1){ 2009 while(out1!=NULL){ 2010 if(getElements(in,out1->name)==NULL) 2011 return out1->name; 2012 out1=out1->next; 2013 } 2014 out1=*out; 2015 } 1963 2016 while(tmpInputs!=NULL){ 1964 2017 maps *tmpMaps=getMaps(out1,tmpInputs->name); … … 2090 2143 else 2091 2144 addToMap(tmpMaps->content,"inRequest","true"); 2145 2092 2146 } 2093 2147 tmpInputs=tmpInputs->next; … … 2244 2298 2245 2299 } 2300 2301 /** 2302 * Cache a file for a given request 2303 */ 2304 void addToCache(maps* conf,char* request,char* content,int length){ 2305 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 2306 if(tmp!=NULL){ 2307 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+6)); 2308 sprintf(fname,"%s/list",tmp->value); 2309 fprintf(stderr,"Cache list : %s\n",fname); 2310 fflush(stderr); 2311 struct stat f_status; 2312 int s=stat(fname, &f_status); 2313 /** 2314 * If the file does not exist, create it 2315 */ 2316 if(s<0){ 2317 FILE* f=fopen(fname,"w+"); 2318 if(f) 2319 fclose(f); 2320 s=stat(fname, &f_status); 2321 } 2322 if(f_status.st_size>=0){ 2323 FILE* f=fopen(fname,"a+"); 2324 char* foname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+64)); 2325 sprintf(foname,"%s/%d.zca",tmp->value,f_status.st_size); 2326 fprintf(stderr,"Cache file : %s\n",foname); 2327 fflush(stderr); 2328 FILE* fo=fopen(foname,"w+"); 2329 char *fcontent=(char*)malloc(sizeof(char)*(strlen(foname)+strlen(request)+3)); 2330 sprintf(fcontent,"%s|%s\n",request,foname); 2331 2332 fwrite(fcontent,sizeof(char),strlen(fcontent),f); 2333 fwrite(content,sizeof(char),length,fo); 2334 fclose(f); 2335 fclose(fo); 2336 } 2337 } 2338 } 2339 2340 char* isInCache(maps* conf,char* request){ 2341 map* tmp=getMapFromMaps(conf,"main","cacheDir"); 2342 if(tmp!=NULL){ 2343 char* fname=(char*)malloc(sizeof(char)*(strlen(tmp->value)+6)); 2344 sprintf(fname,"%s/list",tmp->value); 2345 struct stat f_status; 2346 int s=stat(fname, &f_status); 2347 if(s==0){ 2348 char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 2349 FILE* f=fopen(fname,"r"); 2350 fread(fcontent,sizeof(char),f_status.st_size,f); 2351 char *tmp,*svt; 2352 tmp=strtok_r(fcontent,"\n",&svt); 2353 int lin=0; 2354 while(tmp!=NULL){ 2355 char *tmp1,*svt1; 2356 tmp1=strtok_r(tmp,"|",&svt1); 2357 int hv=-1; 2358 while(tmp1!=NULL){ 2359 fprintf(stderr,"%s %s\n",tmp1,request); 2360 if(hv>0) 2361 return tmp1; 2362 if(strcasecmp(tmp1,request)==0) 2363 hv=1; 2364 tmp1=strtok_r(NULL,"|",&svt1); 2365 } 2366 lin++; 2367 tmp = strtok_r(NULL,"\n",&svt); 2368 } 2369 fclose(f); 2370 } 2371 } 2372 return NULL; 2373 } -
trunk/zoo-kernel/service_internal.h
r274 r280 72 72 #endif 73 73 #include <libxml/parser.h> 74 #include <libxml/xpath.h> 75 74 76 static char* SERVICE_URL; 75 static xmlNsPtr usedNs[ 5];76 static char* nsName[ 5];77 static xmlNsPtr usedNs[10]; 78 static char* nsName[10]; 77 79 static int nbNs=0; 78 80 … … 121 123 int errorException(maps *m, const char *message, const char *errorcode); 122 124 125 int checkForSoapEnvelope(xmlDocPtr); 126 127 void addToCache(maps*,char*,char*,int); 128 char* isInCache(maps*,char*); 129 123 130 #ifdef __cplusplus 124 131 } -
trunk/zoo-kernel/zoo_loader.c
r216 r280 48 48 } 49 49 50 #include "service_internal.h" 51 50 52 xmlXPathObjectPtr extractFromDoc(xmlDocPtr,const char*); 51 53 int runRequest(map*); … … 85 87 #ifdef DEBUG 86 88 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); 88 90 fprintf (stderr, "Request: %s\n", cgiQueryString); 89 91 #endif … … 93 95 if(strncmp(cgiContentType,"text/xml",8)==0 || 94 96 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); 99 116 }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); 103 151 } 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; 118 153 } 119 delete[]buffer;120 154 } 121 155 else{ … … 162 196 xmlInitParser(); 163 197 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 164 222 xmlNodePtr cur = xmlDocGetRootElement(doc); 165 223 char *tval; … … 172 230 if(tval!=NULL) 173 231 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"}; 179 233 for(int j=0;j<3;j++){ 180 char tt[ 35];234 char tt[128]; 181 235 sprintf(tt,"/*[local-name()='%s']",requests[j]); 182 236 xmlXPathObjectPtr reqptr=extractFromDoc(doc,tt); -
trunk/zoo-kernel/zoo_service_loader.c
r277 r280 493 493 textdomain("zoo-services"); 494 494 495 map* lsoap=getMap(request_inputs,"soap"); 496 if(lsoap!=NULL && strcasecmp(lsoap->value,"true")==0) 497 setMapInMaps(m,"main","isSoap","true"); 498 else 499 setMapInMaps(m,"main","isSoap","false"); 495 500 496 501 /** … … 1041 1046 fprintf(stderr,"REQUIRE TO DOWNLOAD A FILE FROM A SERVER : url(%s)\n",tmpv1+1); 1042 1047 #endif 1048 char *tmpx=url_encode(tmpv1+1); 1049 addToMap(tmpmaps->content,tmpn1,tmpx); 1050 1043 1051 #ifndef WIN32 1044 1052 if(CHECK_INET_HANDLE(hInternet)) 1045 1053 #endif 1046 1054 { 1047 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1048 INTERNET_FLAG_NO_CACHE_WRITE,0); 1049 #ifdef DEBUG 1050 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1051 tmpv1+1,res.nDataAlloc,res.nDataLen); 1052 #endif 1053 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1054 if(tmpContent == NULL){ 1055 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1055 char* cached=isInCache(m,tmpv1+1); 1056 if(cached!=NULL){ 1057 fprintf(stderr,"Use cached file: %s\n",cached); 1058 struct stat f_status; 1059 int s=stat(cached, &f_status); 1060 if(s==0){ 1061 map* tmpMap=getMap(tmpmaps->content,"value"); 1062 char* fcontent=(char*)malloc(sizeof(char)*(f_status.st_size+1)); 1063 FILE* f=fopen(cached,"r"); 1064 fread(fcontent,sizeof(char),f_status.st_size,f); 1065 free(tmpMap->value); 1066 tmpMap->value=(char*)malloc((f_status.st_size+1)*sizeof(char)); 1067 memmove(tmpMap->value,fcontent,(f_status.st_size)*sizeof(char)); 1068 free(fcontent); 1069 } 1070 }else{ 1071 res=InternetOpenUrl(hInternet,tmpv1+1,NULL,0, 1072 INTERNET_FLAG_NO_CACHE_WRITE,0); 1073 #ifdef DEBUG 1074 fprintf(stderr,"(%s) content-length : %d,,res.nDataAlloc %d \n", 1075 tmpv1+1,res.nDataAlloc,res.nDataLen); 1076 #endif 1077 char* tmpContent=(char*)calloc((res.nDataLen+1),sizeof(char)); 1078 if(tmpContent == NULL){ 1079 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1080 } 1081 size_t dwRead; 1082 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead); 1083 map* tmpMap=getMap(tmpmaps->content,"value"); 1084 if(tmpMap!=NULL){ 1085 free(tmpMap->value); 1086 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char)); 1087 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char)); 1088 tmpMap->value[res.nDataLen]=0; 1089 if(strlen(tmpContent)!=res.nDataLen){ 1090 char tmp[256]; 1091 sprintf(tmp,"%d",res.nDataLen*sizeof(char)); 1092 addToMap(tmpmaps->content,"size",tmp); 1093 } 1094 addToCache(m,tmpv1+1,tmpContent,res.nDataLen); 1095 } 1096 free(tmpContent); 1056 1097 } 1057 size_t dwRead;1058 InternetReadFile(res, (LPVOID)tmpContent,res.nDataLen, &dwRead);1059 map* tmpMap=getMap(tmpmaps->content,"value");1060 if(tmpMap!=NULL){1061 free(tmpMap->value);1062 tmpMap->value=(char*)malloc((res.nDataLen+1)*sizeof(char));1063 memmove(tmpMap->value,tmpContent,(res.nDataLen)*sizeof(char));1064 tmpMap->value[res.nDataLen]=0;1065 if(strlen(tmpContent)!=res.nDataLen){1066 char tmp[256];1067 sprintf(tmp,"%d",res.nDataLen*sizeof(char));1068 addToMap(tmpmaps->content,"size",tmp);1069 }1070 }1071 free(tmpContent);1072 1098 } 1073 char *tmpx =url_encode(tmpv1+1);1074 addToMap(tmpmaps->content,tmpn1,tmpx );1075 free(tmpx );1099 char *tmpx1=url_encode(tmpv1+1); 1100 addToMap(tmpmaps->content,tmpn1,tmpx1); 1101 free(tmpx1); 1076 1102 addToMap(tmpmaps->content,"Reference",tmpv1+1); 1077 1103 } … … 1413 1439 else 1414 1440 tmpmaps->content=createMap(list[l],(char*)val); 1441 #ifdef DEBUG 1442 fprintf(stderr,"%s\n",val); 1443 #endif 1415 1444 } 1416 #ifdef DEBUG1417 fprintf(stderr,"%s\n",val);1418 #endif1419 1445 xmlFree(val); 1420 free(list[l]); 1446 free(list[l]); 1421 1447 } 1422 1448 } … … 1432 1458 for(int l=0;l<3;l++){ 1433 1459 #ifdef DEBUG 1434 fprintf(stderr,"*** ComplexData %s *** ",coms[l]);1460 fprintf(stderr,"*** ComplexData %s ***\n",coms[l]); 1435 1461 #endif 1436 1462 xmlChar *val=xmlGetProp(cur4,BAD_CAST coms[l]); … … 1440 1466 else 1441 1467 tmpmaps->content=createMap(coms[l],(char*)val); 1468 #ifdef DEBUG 1469 fprintf(stderr,"%s\n",val); 1470 #endif 1442 1471 } 1443 #ifdef DEBUG1444 fprintf(stderr,"%s\n",val);1445 #endif1446 1472 xmlFree(val); 1447 1473 } 1448 1474 } 1475 1449 1476 map* test=getMap(tmpmaps->content,"encoding"); 1450 if(test==NULL || strcasecmp(test->value,"base64")!=0){ 1477 if(test==NULL){ 1478 if(tmpmaps->content!=NULL) 1479 addToMap(tmpmaps->content,"encoding","utf-8"); 1480 else 1481 tmpmaps->content=createMap("encoding","utf-8"); 1482 test=getMap(tmpmaps->content,"encoding"); 1483 } 1484 1485 if(strcasecmp(test->value,"base64")!=0){ 1451 1486 xmlChar* mv=xmlNodeListGetString(doc,cur4->xmlChildrenNode,1); 1452 if(mv==NULL){ 1487 map* ltmp=getMap(tmpmaps->content,"mimeType"); 1488 if(mv==NULL || 1489 (xmlStrcasecmp(cur4->name, BAD_CAST "ComplexData")==0 && 1490 (ltmp==NULL || strncasecmp(ltmp->value,"text/xml",8)==0) )){ 1453 1491 xmlDocPtr doc1=xmlNewDoc(BAD_CAST "1.0"); 1454 1492 int buffersize; 1455 xmlDocSetRootElement(doc1,cur4->xmlChildrenNode); 1493 xmlNodePtr cur5=cur4->children; 1494 while(cur5!=NULL &&cur5->type!=XML_ELEMENT_NODE) 1495 cur5=cur5->next; 1496 xmlDocSetRootElement(doc1,cur5); 1456 1497 xmlDocDumpFormatMemoryEnc(doc1, &mv, &buffersize, "utf-8", 1); 1457 1498 char size[1024]; … … 1578 1619 xmlNodePtr cur1=cur->children; 1579 1620 while(cur1){ 1580 if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){ 1621 /** 1622 * Indentifier 1623 */ 1624 if(xmlStrncasecmp(cur1->name,BAD_CAST "Identifier",xmlStrlen(cur1->name))==0){ 1625 xmlChar *val= 1626 xmlNodeListGetString(doc,cur1->xmlChildrenNode,1); 1627 if(tmpmaps==NULL){ 1628 tmpmaps=(maps*)calloc(1,MAPS_SIZE); 1629 if(tmpmaps == NULL){ 1630 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1631 } 1632 tmpmaps->name=strdup((char*)val); 1633 tmpmaps->content=NULL; 1634 tmpmaps->next=NULL; 1635 } 1636 else 1637 tmpmaps->name=strdup((char*)val);; 1638 xmlFree(val); 1639 } 1640 /** 1641 * Title, Asbtract 1642 */ 1643 else if(xmlStrncasecmp(cur1->name,BAD_CAST "Title",xmlStrlen(cur1->name))==0 || 1644 xmlStrncasecmp(cur1->name,BAD_CAST "Abstract",xmlStrlen(cur1->name))==0){ 1645 xmlChar *val= 1646 xmlNodeListGetString(doc,cur1->xmlChildrenNode,1); 1647 if(tmpmaps==NULL){ 1648 tmpmaps=(maps*)calloc(1,MAPS_SIZE); 1649 if(tmpmaps == NULL){ 1650 return errorException(m, _("Unable to allocate memory."), "InternalError"); 1651 } 1652 tmpmaps->name=strdup("missingIndetifier"); 1653 tmpmaps->content=createMap((char*)cur1->name,(char*)val); 1654 tmpmaps->next=NULL; 1655 } 1656 else{ 1657 if(tmpmaps->content!=NULL) 1658 addToMap(tmpmaps->content, 1659 (char*)cur1->name,(char*)val); 1660 else 1661 tmpmaps->content= 1662 createMap((char*)cur1->name,(char*)val); 1663 } 1664 xmlFree(val); 1665 } 1666 else if(xmlStrncasecmp(cur1->name,BAD_CAST "Output",xmlStrlen(cur1->name))==0){ 1581 1667 /** 1582 1668 * Get every attribute from a Output node … … 1682 1768 dumpMaps(request_output_real_format); 1683 1769 dumpMap(request_inputs); 1770 fprintf(stderr,"\n%i\n",i); 1684 1771 #endif 1685 1772 … … 1689 1776 */ 1690 1777 char *dfv=addDefaultValues(&request_input_real_format,s1->inputs,m,0); 1691 if(strcmp(dfv,"")!=0){ 1778 char *dfv1=addDefaultValues(&request_output_real_format,s1->outputs,m,1); 1779 if(strcmp(dfv1,"")!=0 || strcmp(dfv,"")!=0){ 1692 1780 char tmps[1024]; 1693 snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv); 1781 if(strcmp(dfv,"")!=0){ 1782 snprintf(tmps,1024,_("The <%s> argument was not specified in DataInputs but defined as requested in ZOO ServicesProvider configuration file, please correct your query or the ZOO Configuration file."),dfv); 1783 } 1784 else if(strcmp(dfv1,"")!=0){ 1785 snprintf(tmps,1024,_("The <%s> argument was specified as Output identifier but not defined in the ZOO Configuration File. Please, correct your query or the ZOO Configuration File."),dfv1); 1786 } 1694 1787 map* tmpe=createMap("text",tmps); 1695 1788 addToMap(tmpe,"code","MissingParameterValue"); … … 1711 1804 return 1; 1712 1805 } 1713 addDefaultValues(&request_output_real_format,s1->outputs,m,1);1714 1806 1715 1807 ensureDecodedBase64(&request_input_real_format); … … 1805 1897 addToMap(_tmpMaps->content,"status","0"); 1806 1898 addToMap(_tmpMaps->content,"cwd",ntmp); 1899 map* ltmp=getMap(request_inputs,"soap"); 1900 if(ltmp!=NULL) 1901 addToMap(_tmpMaps->content,"soap",ltmp->value); 1902 else 1903 addToMap(_tmpMaps->content,"soap","false"); 1807 1904 if(cgiCookie!=NULL && strlen(cgiCookie)>0){ 1808 1905 addToMap(_tmpMaps->content,"sessid",strstr(cgiCookie,"=")+1);
Note: See TracChangeset
for help on using the changeset viewer.