2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 import org.apache.axis.client.*;
24 import org.apache.axis.encoding.XMLType;
26 import javax.xml.namespace.QName;
27 import javax.xml.rpc.ParameterMode;
36 public class EBIFetchClient
39 String format = "default";
43 * Creates a new EBIFetchClient object.
45 public EBIFetchClient()
49 call = (Call) new Service().createCall();
50 call.setTargetEndpointAddress(new java.net.URL(
51 "http://www.ebi.ac.uk/ws/services/Dbfetch"));
61 * @return DOCUMENT ME!
63 public String[] getSupportedDBs()
67 call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs"));
68 call.setReturnType(XMLType.SOAP_ARRAY);
70 return (String[]) call.invoke(new Object[] { });
81 * @return DOCUMENT ME!
83 public String[] getSupportedFormats()
87 call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats"));
88 call.setReturnType(XMLType.SOAP_ARRAY);
90 return (String[]) call.invoke(new Object[] { });
101 * @return DOCUMENT ME!
103 public String[] getSupportedStyles()
107 call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles"));
108 call.setReturnType(XMLType.SOAP_ARRAY);
110 return (String[]) call.invoke(new Object[] { });
118 public static void main (String [] args)
120 EBIFetchClient ebi = new EBIFetchClient();
121 String[] result = ebi.fetchData("uniprot:25KD_SARPE;G6PD_HUMAN",
125 java.io.PrintWriter out = new java.io.PrintWriter(
126 new java.io.FileWriter("out.xml"));
129 for(int i=0; i<result.length; i++)
131 out.println(result[i]);
134 }catch(Exception ex){ex.printStackTrace();}
139 public File fetchDataAsFile(String ids, String f, String s)
141 String [] data = fetchData(ids, f, s);
144 outFile = File.createTempFile("jalview", ".xml");
145 outFile.deleteOnExit();
146 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
148 while( index < data.length )
150 out.println(data[index]);
154 }catch(Exception ex){}
161 * @param ids DOCUMENT ME!
162 * @param f DOCUMENT ME!
163 * @param s DOCUMENT ME!
165 * @return DOCUMENT ME!
167 public String[] fetchData(String ids, String f, String s)
169 // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS;
170 // max 50 ids can be added at one time
173 call.setOperationName(new QName("urn:Dbfetch", "fetchData"));
174 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
175 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
176 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
177 call.setReturnType(XMLType.SOAP_ARRAY);
189 return (String[]) call.invoke(new Object[] { ids, format, style });