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
35 public class EBIFetchClient {
\r
37 String format = "default";
\r
38 String style = "raw";
\r
40 public EBIFetchClient() {
\r
42 call = (Call) new Service().createCall();
\r
43 call.setTargetEndpointAddress(new java.net.URL(
\r
44 "http://www.ebi.ac.uk/ws/services/Dbfetch"));
\r
45 } catch (Exception ex) {
\r
49 public String[] getSupportedDBs() {
\r
51 call.setOperationName(new QName("urn:Dbfetch", "getSupportedDBs"));
\r
52 call.setReturnType(XMLType.SOAP_ARRAY);
\r
54 return (String[]) call.invoke(new Object[] { });
\r
55 } catch (Exception ex) {
\r
60 public String[] getSupportedFormats() {
\r
62 call.setOperationName(new QName("urn:Dbfetch", "getSupportedFormats"));
\r
63 call.setReturnType(XMLType.SOAP_ARRAY);
\r
65 return (String[]) call.invoke(new Object[] { });
\r
66 } catch (Exception ex) {
\r
71 public String[] getSupportedStyles() {
\r
73 call.setOperationName(new QName("urn:Dbfetch", "getSupportedStyles"));
\r
74 call.setReturnType(XMLType.SOAP_ARRAY);
\r
76 return (String[]) call.invoke(new Object[] { });
\r
77 } catch (Exception ex) {
\r
82 public String[] fetchData(String ids, String f, String s) {
\r
83 // ids should be of the form uniprot:25KD_SARPE;ADHR_DROPS;
\r
84 // max 50 ids can be added at one time
\r
86 call.setOperationName(new QName("urn:Dbfetch", "fetchData"));
\r
87 call.addParameter("query", XMLType.XSD_STRING, ParameterMode.IN);
\r
88 call.addParameter("format", XMLType.XSD_STRING, ParameterMode.IN);
\r
89 call.addParameter("style", XMLType.XSD_STRING, ParameterMode.IN);
\r
90 call.setReturnType(XMLType.SOAP_ARRAY);
\r
100 return (String[]) call.invoke(new Object[] { ids, format, style });
\r
101 } catch (Exception ex) {
\r
106 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
122 qnameAttachment, JAFDataHandlerSerializerFactory.class,
\r
123 JAFDataHandlerDeserializerFactory.class);
\r
125 call.setReturnType(qnameAttachment);
\r
128 Object ret = call.invoke(new Object[] { arg, format, style });
\r
131 System.err.println("Received null ");
\r
132 throw new AxisFault("", "Received null", null, null);
\r
135 if (ret instanceof String) {
\r
136 System.err.println("Received problem response from server: " +
\r
138 throw new AxisFault("", (String) ret, null, null);
\r
141 if (!(ret instanceof DataHandler)) {
\r
142 //The wrong type of object that what was expected.
\r
143 System.err.println("Received problem response from server:" +
\r
144 ret.getClass().getName());
\r
145 throw new AxisFault("",
\r
146 "Received problem response from server:" +
\r
147 ret.getClass().getName(), null, null);
\r
150 //Still here, so far so good.
\r
151 DataHandler rdh = (DataHandler) ret;
\r
153 //From here we'll just treat the data resource as file.
\r
154 String receivedfileName = rdh.getName(); //Get the filename.
\r
156 if (receivedfileName == null) {
\r
157 System.err.println("Could not get the file name.");
\r
158 throw new AxisFault("", "Could not get the file name.", null,
\r
162 if (arg.equalsIgnoreCase("medline")) {
\r
163 return receivedfileName;
\r
164 } else if (arg.equalsIgnoreCase("interpro")) {
\r
165 return receivedfileName;
\r
167 System.err.println(receivedfileName);
\r
169 } catch (Exception ex) {
\r
170 ex.printStackTrace();
\r