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
21 import org.apache.axis.AxisFault;
\r
22 import org.apache.axis.client.*;
\r
23 import org.apache.axis.encoding.XMLType;
\r
24 import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory;
\r
25 import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory;
\r
27 import javax.activation.DataHandler;
\r
29 import javax.xml.namespace.QName;
\r
30 import javax.xml.rpc.ParameterMode;
\r
37 * @version $Revision$
\r
39 public class EBIFetchClient
\r
42 String format = "default";
\r
43 String style = "raw";
\r
46 * Creates a new EBIFetchClient object.
\r
48 public EBIFetchClient()
\r
52 call = (Call) new Service().createCall();
\r
53 call.setTargetEndpointAddress(new java.net.URL(
\r
54 "http://www.ebi.ac.uk/ws/services/Dbfetch"));
\r
56 catch (Exception ex)
\r
64 * @return DOCUMENT ME!
\r
66 public String[] getSupportedDBs()
\r
70 call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs"));
\r
71 call.setReturnType(XMLType.SOAP_ARRAY);
\r
73 return (String[]) call.invoke(new Object[] { });
\r
75 catch (Exception ex)
\r
84 * @return DOCUMENT ME!
\r
86 public String[] getSupportedFormats()
\r
90 call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats"));
\r
91 call.setReturnType(XMLType.SOAP_ARRAY);
\r
93 return (String[]) call.invoke(new Object[] { });
\r
95 catch (Exception ex)
\r
104 * @return DOCUMENT ME!
\r
106 public String[] getSupportedStyles()
\r
110 call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles"));
\r
111 call.setReturnType(XMLType.SOAP_ARRAY);
\r
113 return (String[]) call.invoke(new Object[] { });
\r
115 catch (Exception ex)
\r
124 * @param ids DOCUMENT ME!
\r
125 * @param f DOCUMENT ME!
\r
126 * @param s DOCUMENT ME!
\r
128 * @return DOCUMENT ME!
\r
130 public String[] fetchData(String ids, String f, String s)
\r
132 // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS;
\r
133 // max 50 ids can be added at one time
\r
136 call.setOperationName(new QName("urn:Dbfetch", "fetchData"));
\r
137 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
138 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
139 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
140 call.setReturnType(XMLType.SOAP_ARRAY);
\r
152 return (String[]) call.invoke(new Object[] { ids, format, style });
\r
154 catch (Exception ex)
\r
163 * @param arg DOCUMENT ME!
\r
164 * @param f DOCUMENT ME!
\r
165 * @param s DOCUMENT ME!
\r
167 * @return DOCUMENT ME!
\r
169 public String fetchDataFile(String arg, String f, String s)
\r
181 call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile"));
\r
182 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
183 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
184 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
186 QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler");
\r
187 call.registerTypeMapping(javax.activation.DataSource.class,
\r
188 qnameAttachment, JAFDataHandlerSerializerFactory.class,
\r
189 JAFDataHandlerDeserializerFactory.class);
\r
191 call.setReturnType(qnameAttachment);
\r
195 Object ret = call.invoke(new Object[] { arg, format, style });
\r
199 System.err.println("Received null ");
\r
200 throw new AxisFault("", "Received null", null, null);
\r
203 if (ret instanceof String)
\r
205 System.err.println("Received problem response from server: " +
\r
207 throw new AxisFault("", (String) ret, null, null);
\r
210 if (!(ret instanceof DataHandler))
\r
212 //The wrong type of object that what was expected.
\r
213 System.err.println("Received problem response from server:" +
\r
214 ret.getClass().getName());
\r
215 throw new AxisFault("",
\r
216 "Received problem response from server:" +
\r
217 ret.getClass().getName(), null, null);
\r
220 //Still here, so far so good.
\r
221 DataHandler rdh = (DataHandler) ret;
\r
223 //From here we'll just treat the data resource as file.
\r
224 String receivedfileName = rdh.getName(); //Get the filename.
\r
226 if (receivedfileName == null)
\r
228 System.err.println("Could not get the file name.");
\r
229 throw new AxisFault("", "Could not get the file name.", null,
\r
233 if (arg.equalsIgnoreCase("medline"))
\r
235 return receivedfileName;
\r
237 else if (arg.equalsIgnoreCase("interpro"))
\r
239 return receivedfileName;
\r
243 System.err.println(receivedfileName);
\r
246 catch (Exception ex)
\r
248 ex.printStackTrace();
\r