00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 package msd_soap_service_pkg;
00017 import java.*;
00018 import java.lang.*;
00019 import java.util.*;
00020 import java.net.URL;
00021 import org.apache.axis.client.Call;
00022 import org.apache.axis.client.Stub;
00023 import org.apache.axis.client.Service;
00024 import org.apache.axis.encoding.XMLType;
00025 import org.apache.axis.utils.Options;
00026 import org.apache.axis.AxisFault;
00027 import javax.xml.namespace.QName;
00028 import org.apache.axis.message.SOAPBodyElement;
00029 import org.apache.axis.message.*;
00030 import msd_soap_types.*;
00031 import com.google.soap.search.*;
00032 import org.apache.axis.message.SOAPHeaderElement;
00033
00034 public class ApiClientTester
00035 {
00036 public static void main(java.lang.String [] args) throws Exception {
00037 try {
00038 long start = System.currentTimeMillis();
00039
00040 Msd_soap_service api_service = new Msd_soap_serviceLocator();
00041
00042 Msd_soap_servicePortType api_port = api_service.getmsd_soap_service();
00043 org.apache.axis.client.Stub stubs = (org.apache.axis.client.Stub) api_port;
00044
00045
00046 stubs.setUsername("geoff");
00047 stubs.setPassword("cc12345678");
00048
00049 java.lang.String sessionName="MyJavaSession";
00050 java.lang.String connName="MyJavaConnection";
00051 java.lang.String queryName="MyJavaQuery";
00052 java.lang.String resName="MyJavaResult";
00053 int otl_buf=50;
00054 java.lang.String sessionID = "my_java_session_number";
00055 java.lang.String sqlSSMQuery = "select s.target_id from ssm_out_tab s where s.session_id = '" + sessionID + "'";
00056 java.lang.String stm= "select e.entry_id, e.accession_code from entry e, author a where e.res_val <= 2.5 and e.entry_id = a.entry_id " +
00057 "and a.last_name = 'HENRICK' and e.accession_code in ( " + sqlSSMQuery + ")";
00058
00059 java.lang.String ssmQuery ="<SSMInput>" +
00060 "<program>" +
00061 "SSM v1.38 // 30/06/2003 // by Eugene B. Krissinel," +
00062 "European Bioinformatics Institute, Hinxton, Cambridge CB1 9SD, UK" +
00063 "</program>" +
00064 "<query>" +
00065 "<type>PDB entry</type>" +
00066 "<pdbcode>9xia</pdbcode>" +
00067 "</query>" +
00068 "<target>" +
00069 "<type>PDB archive</type>" +
00070 "</target>" +
00071 "<selection>" +
00072 "<type>Chain(s)</type>" +
00073 "<chains>*(all)</chains>" +
00074 "</selection>" +
00075 "<percent1>70</percent1>" +
00076 "<percent2>70</percent2>" +
00077 "<sepchains>Yes</sepchains>" +
00078 "<connectivity>Yes</connectivity>" +
00079 "<bestmatch>Yes</bestmatch>" +
00080 "<uniquematch>Yes</uniquematch>" +
00081 "<precision>Normal</precision>" +
00082 "<sorting>RMSD</sorting>" +
00083 "</SSMInput>";
00084
00085 java.lang.Object[] inputArray = new java.lang.Object[2];
00086 inputArray[0]= ssmQuery;
00087 inputArray[1]= sessionID;
00088 int numOfParams = 2;
00089 try {
00090 api_port.msdSSM(numOfParams, inputArray);
00091 System.out.println("msdSSM() method Called successfully.");
00092
00093 int ic =1;
00094 do {
00095 String faultstr="OK";
00096 AxisFault f2 = new AxisFault();
00097 try {
00098 api_port.msdSSMParser(1, sessionID);
00099 } catch (AxisFault f1){
00100 faultstr = f1.getFaultString();
00101 f2 = f1;
00102 }
00103 if(faultstr.equals("Result fille not ready")){
00104 System.out.println("\nXML File not ready...retry: "+ ic);
00105 } else if(faultstr.equals("XML SSM file will not be ready in less than 15 minutes."))
00106 {ic = -2;
00107 }else{
00108 ic = -1;
00109 }
00110
00111 if (ic == -2)
00112 { System.out.println("msdSSMParser() method call failed.");
00113 System.out.println(faultstr);
00114 if (f2 instanceof java.rmi.RemoteException) {
00115 throw (java.rmi.RemoteException)f2;
00116 }
00117 }
00118 long time = System.currentTimeMillis()+ 10000;
00119 long tempTime = System.currentTimeMillis();
00120 while (time > tempTime) {
00121 tempTime=System.currentTimeMillis();
00122
00123 }
00124 ++ic;
00125 } while (ic > 0);
00126
00128
00129 int c = api_port.msdConnect(connName);
00130 int r = api_port.msdResultset(connName, queryName, resName);
00131 int q = api_port.msdQuery(connName, queryName, resName, stm);
00132 System.out.println("\nConnect: " + c + "\nResult: " + r + "\nQuery: "+ q + " : "+ stm + "\n");
00133 int result3 = api_port.msdExecQuery(connName, queryName, resName, otl_buf);
00134 if (result3 == 0)
00135 {System.out.println("\nmsdExecQuery Executed: " + result3 + "\n");
00136
00137
00138 msd_soap_types.Resultset result4 = api_port.msdGetResult(connName, queryName, resName);
00139
00140 java.lang.Object[] dataSet = result4.getR();
00141 java.util.List res = Arrays.asList(dataSet);
00142 int m = res.size();
00143
00144 java.lang.Object[] record = (java.lang.Object[])dataSet[0];
00145 java.util.List rec = Arrays.asList(record);
00146 int n = rec.size();
00147 for (int j=0;j<m;j++)
00148 {
00149
00150
00151
00152 record = (java.lang.Object[])dataSet[j];
00153
00154
00155 System.out.println("Column " + j + " started...\n");
00156
00157 for (int i=0;i<n;i++)
00158 {
00159
00160
00161
00162
00163
00164
00165 System.out.println("Value[" + j + "," + i + "] = " + record[i] + "\n");
00166
00167 }
00168
00169
00170 }
00171 int stts = api_port.msdEndQueryPack(queryName, resName);
00172 System.out.println("\nmsdEndQueryPack status: " + stts + "\n");
00173 stts = api_port.msdEndConnect(connName);
00174 System.out.println("\nmsdEndSession status: " + stts + "\n");
00175 stts = api_port.msdEndSession(sessionName);
00176 System.out.println("\nmsdEndSession status: " + stts + "\n");
00177
00178 }else{
00179 System.out.println("\nmsdExecQuery Failed. " + result3 + "\n");}
00180 long finish = System.currentTimeMillis();
00181 long time = finish-start;
00182 System.out.println("Time taken = "+ time + " milliseconds.");
00183
00184 }
00185 catch (AxisFault f){
00186 System.out.println(f.getFaultString());
00187 }
00188 } catch (Exception e) {
00189 System.err.println(e.toString());
00190 e.printStackTrace();
00191 }
00193 String clientKey = "fGeTRvdQFHLfeNjYlcoRt13M6mKs4SgT";
00194 String directive = "search";
00195 String directiveArg = "KIM HENRICK and 9xia";
00196
00197
00198 GoogleSearch s = new GoogleSearch();
00199 s.setKey(clientKey);
00200
00201
00202 try {
00203 if (directive.equalsIgnoreCase("search")) {
00204 s.setQueryString(directiveArg);
00205 GoogleSearchResult r = s.doSearch();
00206 System.out.println("Google Search Results:");
00207 System.out.println("======================");
00208 System.out.println(r.toString());
00209 } else if (directive.equalsIgnoreCase("cached")) {
00210 System.out.println("Cached page:");
00211 System.out.println("============");
00212 byte [] cachedBytes = s.doGetCachedPage(directiveArg);
00213
00214
00215 String cachedString = new String(cachedBytes);
00216 System.out.println(cachedString);
00217 } else if (directive.equalsIgnoreCase("spell")) {
00218 System.out.println("Spelling suggestion:");
00219 String suggestion = s.doSpellingSuggestion(directiveArg);
00220 System.out.println(suggestion);
00221 } else {
00222 System.err.println("Usage: " +
00223 " <client-key>" +
00224 " (search <query> | cached <url> | spell <phrase>)");
00225 System.exit(1);
00226 }
00227 } catch (GoogleSearchFault f) {
00228 System.out.println("The call to the Google Web APIs failed:");
00229 System.out.println(f.toString());
00230 }
00231
00232 }}