2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
22 import org.apache.axis.client.*;
\r
26 import javax.activation.DataHandler;
\r
27 import org.apache.axis.AxisFault;
\r
28 import org.apache.axis.encoding.XMLType;
\r
29 import javax.xml.rpc.ParameterMode;
\r
30 import javax.xml.namespace.QName;
\r
31 import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
\r
32 import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
\r
35 public class EBIFetchClient
\r
38 String format = "default";
\r
39 String style = "raw";
\r
41 public EBIFetchClient()
\r
44 call = (Call)new Service().createCall();
\r
45 call.setTargetEndpointAddress(new java.net.URL(
\r
46 "http://www.ebi.ac.uk/ws/services/Dbfetch"));
\r
47 }catch(Exception ex){}
\r
51 public String [] getSupportedDBs()
\r
55 call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs"));
\r
56 call.setReturnType(XMLType.SOAP_ARRAY);
\r
57 return (String[]) call.invoke(new Object[]{});
\r
59 }catch(Exception ex){return null;}
\r
62 public String [] getSupportedFormats()
\r
65 call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats"));
\r
66 call.setReturnType(XMLType.SOAP_ARRAY);
\r
67 return (String[]) call.invoke(new Object[] {});
\r
69 }catch(Exception ex){ return null; }
\r
72 public String [] getSupportedStyles()
\r
75 call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles"));
\r
76 call.setReturnType(XMLType.SOAP_ARRAY);
\r
77 return (String[]) call.invoke(new Object[] {});
\r
79 }catch(Exception ex){return null;}
\r
82 public String [] fetchData(String ids, String f, String s)
\r
84 // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS;
\r
85 // max 50 ids can be added at one time
\r
87 call.setOperationName(new QName("urn:Dbfetch", "fetchData"));
\r
88 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
89 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
90 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
91 call.setReturnType(XMLType.SOAP_ARRAY);
\r
99 return (String[]) call.invoke(new Object[] {ids, format, style});
\r
101 }catch(Exception ex){return null;}
\r
105 public String fetchDataFile(String arg, String f, String s)
\r
115 call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile"));
\r
116 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
117 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
118 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
120 QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler");
\r
121 call.registerTypeMapping(javax.activation.DataSource.class,
\r
123 JAFDataHandlerSerializerFactory.class,
\r
124 JAFDataHandlerDeserializerFactory.class);
\r
126 call.setReturnType(qnameAttachment);
\r
129 Object ret = call.invoke(new Object[]
\r
130 {arg, format, style});
\r
134 System.err.println("Received null ");
\r
135 throw new AxisFault("", "Received null", null, null);
\r
137 if (ret instanceof String)
\r
139 System.err.println("Received problem response from server: " + ret);
\r
140 throw new AxisFault("", (String) ret, null, null);
\r
142 if (! (ret instanceof DataHandler))
\r
144 //The wrong type of object that what was expected.
\r
145 System.err.println("Received problem response from server:" +
\r
146 ret.getClass().getName());
\r
147 throw new AxisFault("", "Received problem response from server:" +
\r
148 ret.getClass().getName(), null, null);
\r
151 //Still here, so far so good.
\r
152 DataHandler rdh = (DataHandler) ret;
\r
154 //From here we'll just treat the data resource as file.
\r
155 String receivedfileName = rdh.getName(); //Get the filename.
\r
157 if (receivedfileName == null)
\r
159 System.err.println("Could not get the file name.");
\r
160 throw new AxisFault("", "Could not get the file name.", null, null);
\r
162 if (arg.equalsIgnoreCase("medline"))
\r
164 return receivedfileName;
\r
166 else if (arg.equalsIgnoreCase("interpro"))
\r
168 return receivedfileName;
\r
171 System.err.println(receivedfileName);
\r
172 }catch(Exception ex)
\r
174 ex.printStackTrace();
\r