Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

msd_soap_client_all.cc

00001 #include "msd_soapH.h"
00002 #include "msd_soap_service.nsmap"
00003 #include <iostream>
00004 #include <string.h>
00005 using namespace std;
00007 //
00008 //      PDBe Data Warehouse client for msd API Web Services
00009 //
00011 // To access a stand-alone server on a port: msd_soap_service[] = "IP:PORT";
00012 // use "http://" to include HTTP header: msd_soap_service[] = "http://IP:PORT";
00013 // const char msd_soap_service[] = "parrot.ebi.ac.uk:8099"
00014 // const char msd_soap_service[] = "http://parrot.ebi.ac.uk:8099";
00015 
00016 
00017 
00018 //const char msd_soap_service[] = "http://phoenix.ebi.ac.uk:8099/cgi-bin/msd_soap_service.cgi";
00019 const char msd_soap_service[] = "http://parrot.ebi.ac.uk:8099/cgi-bin/msd_soap_service.cgi";
00020 const char endpoint[] = "http://websrv.cs.fsu.edu/~engelen/varparam.cgi";
00021 #define N 8
00022 
00023 
00024 
00025 int main(int argc, char **argv)
00026 {   
00027  
00028   struct soap *soap;
00029   soap= soap_new();
00030   struct ns__varPolyParamTestResponse r;
00031     int n;
00032     xsd__anyType *p[N];
00033         char* tmp;
00034         tmp=(char*)soap_malloc(soap, strlen(msd_soap_service)+1);
00035         strcpy(tmp,msd_soap_service);
00036         p[0] = new xsd__anyURI(tmp);
00037         tmp=(char*)soap_malloc(soap, strlen(endpoint)+1);
00038         strcpy(tmp,endpoint);
00039     p[1] = new xsd__string(tmp);
00040     p[2] = new xsd__boolean(false);
00041     p[3] = new xsd__dateTime(1234567);
00042     p[4] = new xsd__double(1234567.89);
00043     p[5] = new xsd__base64Binary("encoded in base64");
00044     p[6] = new xsd__hexBinary("encoded in hex");
00045     p[7] = new array(3);
00046     (*p[7])[0] = new xsd__int(7);
00047     (*p[7])[1] = new xsd__token("x");
00048         (*p[7])[2] = new xsd__float(1234.8765);
00049   //soap->keep_alive = 1; 
00050   if (! soap)
00051   {
00052    printf ("\nCan not allocate environment for Web services.\n");
00053    return (1);
00054   }
00055         //struct soap soap;
00056     //soap_init(&soap);
00057   int result;
00058   
00059   char* logstr="whouse/whouse@msdtrnsd";
00060   char* logs;
00061   logs = (char*)soap_malloc(soap, strlen(logstr)+1);
00062   strcpy(logs, logstr); 
00063   char* sql;
00064   //char* statement="select /*+ INDEX_COMBINE(component component_id) */ *  from component where "
00065   //                   "component_id >= :f<int> and component_id <= 50000*:f<int>";
00066   
00067   char* statement="select /*+ INDEX_COMBINE(component component_id) */ *  from component where "
00068                      "component_id >= 1 and component_id <= 200";
00069   sql = (char*)malloc(strlen(statement)+1);
00070   strcpy(sql, statement);
00071   char *argvNew[5];
00072   int pid;
00073   int nomtabs=35;
00074   printf("Content-type: text/html\r\n\r\n<html><h2>Client for PDBe API Framework Web Services from %s</h2><pre>\n", msd_soap_service);
00075   
00076   char* xmlfn;
00077   char* xmlfile="/homes/sobhany/apache/htdocs/output.xml"; // entry for XML parser
00078   xmlfn = (char*)soap_malloc(soap, strlen(xmlfile)+1);
00079   strcpy(xmlfn, xmlfile);
00080 //  char* par[3]={"<SSMInput>\n"
00081 //  "<query>\n"
00082 //    "<type>PDB entry</type>\n"
00083 //    "<pdbcode>1sar</pdbcode>\n"
00084 //  "</query>\n"
00085 //  "<target>\n"
00086 //    "<type>PDB archive</type>\n"
00087 //  "</target>\n"
00088 //  "<selection>\n"
00089 //    "<type>Chain(s)</type>\n"
00090 //    "<chains>*(all)</chains>\n"
00091 //  "</selection>\n"
00092 //  "<percent1>70</percent1>\n"
00093 //  "<percent2>70</percent2>\n"
00094 //  "<sepchains>Yes</sepchains>\n"
00095 //  "<connectivity>Yes</connectivity>\n"
00096 //  "<bestmatch>Yes</bestmatch>\n"
00097 //  "<uniquematch>Yes</uniquematch>\n"
00098 //  "<precision>Normal</precision>\n"
00099 //  "<sorting>RMSD</sorting>\n"
00100 //"</SSMInput>\n" , "MyPar2", "MyPar3"};
00102   //xsd__anyType * par[3];
00103  // par[0] = new xsd__string("1234567");
00104  // par[1] = new xsd__string("8901112");
00105  // par[2]=new array(3);
00106   //(*par[2])[0] = new xsd__string("<SSMInput>"
00107   //struct ns__input_params* inp;
00108   array * par;
00109   par = new array(3);
00110   char* temp="<SSMInput>"
00111   "<query>"
00112     "<type>PDB entry</type> "
00113     "<pdbcode>1sar</pdbcode>  "
00114   "</query> "
00115   "<target> "
00116     "<type>PDB archive</type> "
00117   "</target>\n  "
00118   "<selection>  "
00119     "<type>\n   Chain(s)</type>\n"
00120     "   <chains>*(all)</chains>\n"
00121   "   </selection>"
00122   "<percent1>70</percent1>     \n \n"
00123   "<percent2>70</percent2>"
00124   "<sepchains> Yes     </sepchains>"
00125   "<connectivity> Yes     </connectivity>  "
00126   "<bestmatch>\n Yes</bestmatch>"
00127   "<uniquematch>Yes</uniquematch>"
00128   "<precision>Normal</precision>"
00129   "<sorting>RMSD</sorting>\n   \n"
00130   "</SSMInput>  ";
00131   char* buffers;
00132   buffers = (char*)soap_malloc(soap, strlen(temp)+1);
00133   strcpy(buffers,temp);
00134   (*par)[0]= new xsd__string(buffers);
00135   (*par)[1]= new xsd__string("AAAA");
00136   (*par)[2]= new xsd__string("BBBB");
00137   
00138 //  char* par[3]={"<query>"
00139 //    "<type>PDB entry</type>"
00140 //    "<pdbcode>1sar</pdbcode>"
00141 //  "</query>"
00142 //  "<target>"
00143 //    "<type>PDB archive</type>"
00144 //  "</target>"
00145 //  "<selection>"
00146 //    "<type>Chain(s)</type>"
00147 //    "<chains>*(all)</chains>"
00148 //  "</selection>"
00149 //  "<percent1>70</percent1>"
00150 //  "<percent2>70</percent2>"
00151 //  "<sepchains>Yes</sepchains>"
00152 //  "<connectivity>Yes</connectivity>"
00153 //  "<bestmatch>Yes</bestmatch>"
00154 //  "<uniquematch>Yes</uniquematch>"
00155 //  "<precision>Normal</precision>"
00156 //  "<sorting>RMSD</sorting>"
00157 //  "</SSMInput>","MyPar2", "MyPar3"};
00158 
00159   //(*par[2])[1] = new xsd__string("MyPar2");
00160   //(*par[2])[2] = new xsd__string("MyPar3");
00161   
00162   char* cmdexec;
00163   char* cmd="/ebi/msd/ssm/cgi-bin/ssm -offline /homes/sobhany/apache/htdocs/input.xml /homes/sobhany/apache/htdocs/output.xml /ebi/msd/ssm/ssmdata/ssmsrv.conf_parrot > /homes/sobhany/apache/htdocs/ssmws.log";
00164   //char* cmd="/ebi/msd/ssm/cgi-bin/ssmserver  -xmlsample mysample.xml";
00165   //char* cmd="/ebi/msd/ssm/cgi-bin/ssmserver -offline /homes/sobhany/apache/htdocs/input.xml /homes/sobhany/apache/htdocs/output.xml /ebi/msd/ssm/ssmdata/ssmsrv.conf";
00166   char* session="AAAA";
00167   cmdexec = (char*)malloc(strlen(cmd)+1);
00168   strcpy(cmdexec, cmd);
00169   
00170   if (soap_call_ns__msd_ssm(soap, msd_soap_service, "urn:msd_soap_service#msd-ssm",3, par, result)== SOAP_OK) //http://parrot.ebi.ac.uk:8099/cgi-bin/msd_soap_service#msd-conninit
00171   { printf ("\nPDBe SSM Web Service initialized...\n");
00172   }
00173   else
00174   { printf ("\nPDBe SSM Web Service failed...(Error %d) \n", result);
00175         soap_print_fault(soap, stderr);
00176     soap_print_fault_location(soap, stderr);
00177   } 
00178   
00179   
00181   array * fasta_params;
00182   fasta_params = new array(2); // 2
00183   //(*fasta_params)[0]= new xsd__string("MMM000");
00184   //(*fasta_params)[1]= new xsd__string("VMVSPMASIRSDEGMPIFVGDRSNVQDGVVLHALETINEEGEPIEDNI");
00185   //(*fasta_params)[2]= new xsd__string("1"); //"1e-10"
00186   //(*fasta_params)[3]= new xsd__string("PDB");
00187   
00188  (*fasta_params)[0]= new xsd__string("MMM000"); 
00189 
00190 char* instr ="<fatsa>     "
00191  " <sequence>    VMVSPMASIRSDEGMPIFVGDRSNVQDGVVLHALETINEEGEPIEDNI   \n</sequence>"
00192  " <evalue>     1e-10      </evalue>\n"
00193 "   \n<library>     PDB   </library>   "
00194 "  </fatsa>  \n";
00195 char* buffers;
00196 buffers = (char*)soap_malloc(soap, strlen(instr)+1);
00197 strcpy(buffers,instr);
00198 (*fasta_params)[1]= new xsd__string(buffers); 
00199  
00200 
00201   
00202   
00203   if (soap_call_ns__msd_fasta(soap, msd_soap_service, "urn:msd_soap_service#msd-fasta", 4, fasta_params, result)== SOAP_OK) //http://parrot.ebi.ac.uk:8099/cgi-bin/msd_soap_service#msd-conninit
00204   { printf ("\nPDBe FASTA Server Service initialized...\n");
00205   }
00206   else
00207   { printf ("\nPDBe FASTA Server Service failed...(Error %d) \n", result);
00208         soap_print_fault(soap, stderr);
00209     soap_print_fault_location(soap, stderr);
00210   } 
00212   
00213   
00214   
00215   array * app_params;
00216   app_params = new array(3);
00217   (*app_params)[0]= new xsd__string("/tmp_mnt/net_nfs6/vol1/homes/sobhany/apache/cgi-bin/msd_main");
00218   (*app_params)[1]= new xsd__string(" > ");
00219   (*app_params)[2]= new xsd__string("/homes/sobhany/apache/htdocs/appserv.txt");
00220   
00221   
00222   // Call appserver
00223   //char* app="/tmp_mnt/net_nfs6/vol1/homes/sobhany/apache/cgi-bin/msd_main > /homes/sobhany/apache/htdocs/appserv.txt";
00224   //cmdexec = (char*)malloc(strlen(app)+1);
00225   //strcpy(cmdexec, app);
00226   
00227   
00228   
00229   if (soap_call_ns__msd_appserv(soap, msd_soap_service, "urn:msd_soap_service#msd-appserv", 3, app_params, result)== SOAP_OK) //http://parrot.ebi.ac.uk:8099/cgi-bin/msd_soap_service#msd-conninit
00230   { printf ("\nPDBe Application Server Service initialized...\n");
00231   }
00232   else
00233   { printf ("\nPDBe Application Server Service failed...(Error %d) \n", result);
00234         soap_print_fault(soap, stderr);
00235     soap_print_fault_location(soap, stderr);
00236   } 
00237   
00238   if (soap_call_ns__msd_srv_pxml(soap, msd_soap_service, "urn:msd_soap_service#msd-srv-pxml", session, result)== SOAP_OK) //http://parrot.ebi.ac.uk:8099/cgi-bin/msd_soap_service#msd-conninit
00239   { printf ("\nPDBe SSM XML Parser Service initialized...\n");
00240   }
00241   else
00242   { printf ("\nPDBe SSM XML Parser Service failed...(Error %d) \n", result);
00243         soap_print_fault(soap, stderr);
00244     soap_print_fault_location(soap, stderr);
00245   } 
00246   
00247   
00248   if (soap_call_ns__msd_conninit(soap, msd_soap_service, "urn:msd_soap_service#msd-conninit",0,result)== SOAP_OK) //http://parrot.ebi.ac.uk:8099/cgi-bin/msd_soap_service#msd-conninit
00249   { printf ("\nConnection to the PDBe initialized...\n");
00250   }
00251   else
00252   { printf ("Connection failed to the MSD...(Error %d) \n", result);
00253         soap_print_fault(soap, stderr);
00254     soap_print_fault_location(soap, stderr);
00255   } 
00256   
00257   if (soap_call_ns__msd_server_attach(soap, msd_soap_service, "urn:msd_soap_service#msd-server-attach",0,"msdtrnsd",result)== SOAP_OK)
00258   { printf ("Successfull Attach to the MSD...\n");
00259   }
00260   else
00261   { 
00262         printf ("Server not attached.(Error %d) \n", result);
00263         soap_print_fault(soap, stderr);
00264     soap_print_fault_location(soap, stderr);
00265   }
00266   if (soap_call_ns__msd_session_begin(soap, msd_soap_service, "urn:msd_soap_service#msd-session-begin",0,"whouse","whouse",result)== SOAP_OK)
00267   { printf ("Successfull login to the MSD...\nSession begin...\n");
00268   }
00269   else
00270   { printf ("Login failed to the MSD...(Error %d) \n", result);
00271         soap_print_fault(soap, stderr);
00272     soap_print_fault_location(soap, stderr);
00273   }
00274   
00275                     
00276   if(soap_call_ns__msd_sqlinit(soap, msd_soap_service, "urn:msd_soap_service#msd-sqlinit",0,0,sql,result)== SOAP_OK)
00277         { printf ("Successfull SQL initialization...\n");
00278   //printf ("Successfull Making Record...\n");
00279   }
00280   else
00281   {  printf ("SQL init  failed...(Error %d) \n", result);
00282           soap_print_fault(soap, stderr);
00283     soap_print_fault_location(soap, stderr);
00284   }
00285 //  if(soap_call_ns__msd_setcriteria(&soap, msd_soap_service, NULL,0,0,"i",1,result))
00286 //  {soap_print_fault(&soap, stderr);
00287 //    soap_print_fault_location(&soap, stderr);
00288 //  }
00289 // else
00290 //  { printf ("Successfull criteria setting...\n");
00291 //  }
00292  
00293   
00294   //if(soap_call_ns__msd_makerecord(soap, msd_soap_service, "urn:msd_soap_service#msd-makerecord",0,0,result)== SOAP_OK)
00295   
00296  // { printf ("\nSuccessfull record structure...\n");
00297   //}
00298   //else
00299   //{ printf ("\nRecord structure failed...(Error %d) \n", result);
00300 //        soap_print_fault(soap, stderr);
00301 //    soap_print_fault_location(soap, stderr);
00302 //  }
00303   
00304   
00305   
00306   //while (soap_call_ns__msd_gethits(soap, msd_soap_service, "urn:msd_soap_service#msd-gethits",0,0,result)<3)
00307   //{
00308  //    if(soap_call_ns__msd_getnext(soap, msd_soap_service, "urn:msd_soap_service#msd-getnext",0,0,result)==SOAP_OK) 
00309 //        {printf ("\nSuccessfull getnext...\n");}
00310         // else
00311   //   { printf ("\nGetnext failed...\n");
00312         //   soap_print_fault(soap, stderr);
00313   //     soap_print_fault_location(soap, stderr);
00314   //   }
00315  // }
00316   if(soap_call_ns__msd_logoff(soap, msd_soap_service, "urn:msd_soap_service#msd-logoff",0,result)== SOAP_OK)
00317   
00318   { printf ("\nSuccessfull logoff...\n");
00319   }
00320   else
00321   { soap_print_fault(soap, stderr);
00322     soap_print_fault_location(soap, stderr);
00323   }
00324   if(soap_call_ns__msd_delete_connect_obj(soap, msd_soap_service, "urn:msd_soap_service#msd-delete-connect-obj",0,result)== SOAP_OK)
00325   
00326  
00327   { printf ("\nSuccessfull delete of connect object...\n");
00328   }
00329   else
00330   { soap_print_fault(soap, stderr);
00331     soap_print_fault_location(soap, stderr);
00332   }
00333  if(soap_call_ns__msd_get_tables_relations(soap, msd_soap_service, "urn:msd_soap_service#msd-get-tables-relations",logs,result)== SOAP_OK)
00334   { printf ("\nSuccessfull Getting Relations...\n");
00335   }
00336   else
00337   { printf ("Getting relations failed...(Error %d) \n", result);
00338         soap_print_fault(soap, stderr);
00339     soap_print_fault_location(soap, stderr);
00340   }
00341   if(soap_call_ns__msd_get_datamodel(soap, msd_soap_service, "urn:msd_soap_service#msd-get-datamodel", logs,result)== SOAP_OK)
00342   { printf ("\nSuccessfull Getting Data Model...\n");
00343   }
00344   else
00345   { printf ("Getting Data Model failed...(Error %d) \n", result);
00346         soap_print_fault(soap, stderr);
00347     soap_print_fault_location(soap, stderr);
00348   }
00349   
00350   //if(soap_call_ns__msd_lisp_eval(soap, msd_soap_service, "urn:msd_soap_service#msd-lisp-eval",result)== SOAP_OK)
00351   //{ printf ("\nSuccessfull System Call...\n");
00352   // }
00353   //else
00354   //{ printf ("System call  failed...(Error %d) \n", result);
00355   //    soap_print_fault(soap, stderr);
00356   //  soap_print_fault_location(soap, stderr);
00357   //}
00359   if (soap_call_ns__varPolyParamTest(soap, msd_soap_service, "urn:msd_soap_service#varPolyParamTest", N, p, r))
00360       soap_print_fault(soap, stderr);
00361     else
00362     { cout << "Server has echoed:" << endl;
00363       for (int i = 0; i < r.__size; i++)
00364       {   printf("p[%i] = ",i);
00365                   p[i]->print();
00366                   cout << endl;
00367                   printf("r.param[%i] = ",i);
00368               r.param[i]->print();
00369           cout <<endl;
00370           }
00371     }
00372     for (int i = 0; i < N; i++){
00373           delete p[i];
00374         }
00375   { if (soap_call_ns__varStringParamTest(soap, msd_soap_service, "urn:msd_soap_service#varStringParamTest", argc, argv, n))
00376       soap_print_fault(soap, stderr);
00377     else
00378       printf("Server has responded to %d strings\n", n);
00379   }
00380   
00381   
00382   printf("</pre></html>\n");
00383   //soap_destroy(soap);
00384   soap_end(soap);
00385   free(soap);
00386   return 0;
00387 }
00388 
00389 
00391 //
00392 //      Namespace Definition Table
00393 //
00395 
00397 //struct Namespace namespaces[] =  
00398 //{   // {"ns-prefix", "ns-name" [, "ns-pattern"]}  
00399 //   {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},  
00400 //   {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},  
00401 //   {"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance"},  
00402 //   {"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema"},  
00403 //   {"t", "urn:msd_soap_types"},
00404 //   {"h", "urn:msd_soap_handles"},
00405 //   {"ns", "urn:msd_soap_service"},
00406 //   {NULL, NULL}  
00407 //};
00409 //if (soap_call_ns__msd_rlogin(soap, msd_soap_service, "urn:msd_soap_service#msd-rlogin",0, logstr,result)== SOAP_OK)
00410   //{ printf ("Successfull Login to the MSD...\n");
00411   //}
00412   //else
00413  // { printf ("Login failed to the MSD...(Error %d) \n", result);
00414  //     soap_print_fault(soap, stderr);
00415  //   soap_print_fault_location(soap, stderr);
00416  // }
00417 

Generated on Fri Apr 16 13:47:41 2004 for MSDAPI by doxygen 1.3.4-20031005