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
29 import javax.activation.DataHandler;
\r
31 import javax.xml.namespace.QName;
\r
32 import javax.xml.rpc.ParameterMode;
\r
39 * @version $Revision$
\r
41 public class EBIFetchClient
\r
44 String format = "default";
\r
45 String style = "raw";
\r
48 * Creates a new EBIFetchClient object.
\r
50 public EBIFetchClient()
\r
54 call = (Call) new Service().createCall();
\r
55 call.setTargetEndpointAddress(new java.net.URL(
\r
56 "http://www.ebi.ac.uk/ws/services/Dbfetch"));
\r
58 catch (Exception ex)
\r
66 * @return DOCUMENT ME!
\r
68 public String[] getSupportedDBs()
\r
72 call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs"));
\r
73 call.setReturnType(XMLType.SOAP_ARRAY);
\r
75 return (String[]) call.invoke(new Object[] { });
\r
77 catch (Exception ex)
\r
86 * @return DOCUMENT ME!
\r
88 public String[] getSupportedFormats()
\r
92 call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats"));
\r
93 call.setReturnType(XMLType.SOAP_ARRAY);
\r
95 return (String[]) call.invoke(new Object[] { });
\r
97 catch (Exception ex)
\r
106 * @return DOCUMENT ME!
\r
108 public String[] getSupportedStyles()
\r
112 call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles"));
\r
113 call.setReturnType(XMLType.SOAP_ARRAY);
\r
115 return (String[]) call.invoke(new Object[] { });
\r
117 catch (Exception ex)
\r
126 * @param ids DOCUMENT ME!
\r
127 * @param f DOCUMENT ME!
\r
128 * @param s DOCUMENT ME!
\r
130 * @return DOCUMENT ME!
\r
132 public String[] fetchData(String ids, String f, String s)
\r
134 // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS;
\r
135 // max 50 ids can be added at one time
\r
138 call.setOperationName(new QName("urn:Dbfetch", "fetchData"));
\r
139 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
140 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
141 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
142 call.setReturnType(XMLType.SOAP_ARRAY);
\r
154 return (String[]) call.invoke(new Object[] { ids, format, style });
\r
156 catch (Exception ex)
\r
165 * @param arg DOCUMENT ME!
\r
166 * @param f DOCUMENT ME!
\r
167 * @param s DOCUMENT ME!
\r
169 * @return DOCUMENT ME!
\r
171 public String fetchDataFile(String arg, String f, String s)
\r
183 call.setOperationName(new QName("urn:Dbfetch", "fetchDataFile"));
\r
184 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
185 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
186 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
188 QName qnameAttachment = new QName("urn:Dbfetch", "DataHandler");
\r
189 call.registerTypeMapping(javax.activation.DataSource.class,
\r
190 qnameAttachment, JAFDataHandlerSerializerFactory.class,
\r
191 JAFDataHandlerDeserializerFactory.class);
\r
193 call.setReturnType(qnameAttachment);
\r
197 Object ret = call.invoke(new Object[] { arg, format, style });
\r
201 System.err.println("Received null ");
\r
202 throw new AxisFault("", "Received null", null, null);
\r
205 if (ret instanceof String)
\r
207 System.err.println("Received problem response from server: " +
\r
209 throw new AxisFault("", (String) ret, null, null);
\r
212 if (!(ret instanceof DataHandler))
\r
214 //The wrong type of object that what was expected.
\r
215 System.err.println("Received problem response from server:" +
\r
216 ret.getClass().getName());
\r
217 throw new AxisFault("",
\r
218 "Received problem response from server:" +
\r
219 ret.getClass().getName(), null, null);
\r
222 //Still here, so far so good.
\r
223 DataHandler rdh = (DataHandler) ret;
\r
225 //From here we'll just treat the data resource as file.
\r
226 String receivedfileName = rdh.getName(); //Get the filename.
\r
228 if (receivedfileName == null)
\r
230 System.err.println("Could not get the file name.");
\r
231 throw new AxisFault("", "Could not get the file name.", null,
\r
235 if (arg.equalsIgnoreCase("medline"))
\r
237 return receivedfileName;
\r
239 else if (arg.equalsIgnoreCase("interpro"))
\r
241 return receivedfileName;
\r
245 System.err.println(receivedfileName);
\r
248 catch (Exception ex)
\r
250 ex.printStackTrace();
\r