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
23 import org.apache.axis.client.*;
\r
24 import org.apache.axis.encoding.XMLType;
\r
26 import javax.xml.namespace.QName;
\r
27 import javax.xml.rpc.ParameterMode;
\r
34 * @version $Revision$
\r
36 public class EBIFetchClient
\r
39 String format = "default";
\r
40 String style = "raw";
\r
43 * Creates a new EBIFetchClient object.
\r
45 public EBIFetchClient()
\r
49 call = (Call) new Service().createCall();
\r
50 call.setTargetEndpointAddress(new java.net.URL(
\r
51 "http://www.ebi.ac.uk/ws/services/Dbfetch"));
\r
53 catch (Exception ex)
\r
61 * @return DOCUMENT ME!
\r
63 public String[] getSupportedDBs()
\r
67 call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs"));
\r
68 call.setReturnType(XMLType.SOAP_ARRAY);
\r
70 return (String[]) call.invoke(new Object[] { });
\r
72 catch (Exception ex)
\r
81 * @return DOCUMENT ME!
\r
83 public String[] getSupportedFormats()
\r
87 call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats"));
\r
88 call.setReturnType(XMLType.SOAP_ARRAY);
\r
90 return (String[]) call.invoke(new Object[] { });
\r
92 catch (Exception ex)
\r
101 * @return DOCUMENT ME!
\r
103 public String[] getSupportedStyles()
\r
107 call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles"));
\r
108 call.setReturnType(XMLType.SOAP_ARRAY);
\r
110 return (String[]) call.invoke(new Object[] { });
\r
112 catch (Exception ex)
\r
118 public static void main (String [] args)
\r
120 EBIFetchClient ebi = new EBIFetchClient();
\r
121 String[] result = ebi.fetchData("uniprot:25K89D_SARPE;G6PblobD_HUMAN",
\r
125 java.io.PrintWriter out = new java.io.PrintWriter(
\r
126 new java.io.FileWriter("out.xml"));
\r
129 for(int i=0; i<result.length; i++)
\r
131 out.println(result[i]);
\r
134 }catch(Exception ex){ex.printStackTrace();}
\r
139 public File fetchDataAsFile(String ids, String f, String s)
\r
141 String [] data = fetchData(ids, f, s);
\r
142 File outFile = null;
\r
144 outFile = File.createTempFile("jalview", ".xml");
\r
145 outFile.deleteOnExit();
\r
146 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
\r
148 while( index < data.length )
\r
150 out.println(data[index]);
\r
154 }catch(Exception ex){}
\r
161 * @param ids DOCUMENT ME!
\r
162 * @param f DOCUMENT ME!
\r
163 * @param s DOCUMENT ME!
\r
165 * @return DOCUMENT ME!
\r
167 public String[] fetchData(String ids, String f, String s)
\r
169 // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS;
\r
170 // max 50 ids can be added at one time
\r
173 call.setOperationName(new QName("urn:Dbfetch", "fetchData"));
\r
174 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
175 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
176 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
177 call.setReturnType(XMLType.SOAP_ARRAY);
\r
189 return (String[]) call.invoke(new Object[] { ids, format, style });
\r
191 catch (Exception ex)
\r