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

msdsoapTest.cc

00001 
00002 #include "msd_soapH.h"
00003 #include "msd_soap_service.nsmap"
00004 
00005 
00006 #include <iostream>
00007 #include <string.h>
00008 using namespace std;
00009 
00010 const char msd_soap_service[] = "http://www.ebi.ac.uk/msd-srv/msdsoap";
00011 
00012 static void *dime_write_open(struct soap *soap, const char *id, const char *type, const char *options)
00013 { FILE *handle = NULL;
00014    handle = fopen((char*)soap->user, "wb");
00015   if (handle)
00016     printf("Streaming result XML file id=%s type=%s into file %s\n", id, type, (char*)soap->user);
00017   else
00018   { soap->error = SOAP_EOF; // could not open file for writing
00019     soap->errnum = errno; // get reason
00020   }
00021   return (void*)handle;
00022 }
00023 
00024 static void dime_write_close(struct soap *soap, void *handle)
00025 { fclose((FILE*)handle);
00026 }
00027 
00028 static int dime_write(struct soap *soap, void *handle, const char *buf, size_t len)
00029 { size_t nwritten;
00030   while (len)
00031   { nwritten = fwrite(buf, 1, len, (FILE*)handle);
00032     if (!nwritten)
00033     { soap->errnum = errno; // get reason
00034       return SOAP_EOF;
00035     }
00036     len -= nwritten;
00037     buf += nwritten;
00038   }
00039   return SOAP_OK;
00040 }
00041 
00042 
00043 int main(int argc, char **argv)
00044 {   
00045  
00046   struct soap soap;
00047   xsd__base64Binary bindata;
00048   char *name;
00049   const char *url;
00050   
00051   soap_init(&soap);
00052 
00053   soap.accept_timeout = 600;    
00054   soap.send_timeout = 60; 
00055   soap.recv_timeout = 300; 
00056    
00057   if (! &soap)
00058   {
00059    printf ("\nCan not allocate environment for Web services.\n");
00060    return (1);
00061   }
00062   int result;
00063   
00064   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);
00065   
00066  array * params;
00067  params = new array(2);
00068   char* query="<SSMInput>"
00069   "<query>"
00070     "<type>PDB entry</type> "
00071     "<pdbcode>1pmb</pdbcode>  " 
00072   "</query> "
00073   "<target> "
00074     "<type>PDB archive</type> "
00075   "</target>\n  "
00076   "<selection>  "
00077     "<type>Chain(s)</type>\n"
00078     "   <chains>*(all)</chains>\n"
00079   "   </selection>"
00080   "<percent1>70</percent1>     \n \n"
00081   "<percent2>70</percent2>"
00082   "<sepchains>Yes</sepchains>"
00083   "<connectivity>Yes</connectivity>  "
00084   "<bestmatch>Yes</bestmatch> "
00085   "<uniquematch>Yes</uniquematch>"
00086   "<precision>Normal</precision>"
00087   "<sorting>RMSD</sorting>\n   \n"
00088   "</SSMInput>  "; 
00089   char* buffers;
00090   buffers = (char*)soap_malloc(&soap, strlen(query)+1);
00091   strcpy(buffers,query);
00092   char* sessionid = (char*)soap_malloc(&soap,32);
00093   sprintf(sessionid, "my_cpp_session_number");
00094   (*params)[0]= new xsd__string(buffers);
00095   (*params)[1]= new xsd__string(sessionid); 
00096  
00097   if (soap_call_ns4__msdSSM(&soap, msd_soap_service, "urn:msd_soap_service#msdSSM", 2, params, result)== SOAP_OK) 
00098   { printf ("\nmsdSSM() method called successfully...\n");
00099   }
00100   else
00101   { printf ("\nmsdSSM() method call failed...(Error %d) \n", result);
00102         soap_print_fault(&soap, stderr);
00103     soap_print_fault_location(&soap, stderr);
00104   } 
00105 
00106     char* outfile="my_xml_res_4_cpp.xml";
00107         soap.user = (void*)outfile;
00108         soap.fdimewriteopen = dime_write_open;
00109     soap.fdimewriteclose = dime_write_close;
00110     soap.fdimewrite = dime_write;
00111     soap.connect_timeout = 10;
00112          if (soap_call_ns4__msdGetDime(&soap, msd_soap_service, "urn:msd_soap_service#msdGetDime", 0, sessionid, bindata))
00113       soap_print_fault(&soap, stderr);
00114      else 
00115       printf("Got file type=%s through streaming DIME\n", bindata.type?bindata.type:""); // image.__ptr = file handle and image.__size == 0 when streaming was used
00116   
00117   
00118   
00119 
00120   
00121   printf("</pre></html>\n");
00122   //soap_destroy(&soap);
00123   soap_end(&soap);
00124   soap_free(&soap);
00125   soap_done(&soap);
00126   return 0;
00127 }
00128 

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