final String token = parameters.getParameter(
MetLinParameters.SECURITY_TOKEN).getValue();
MetaboliteSearchRequest searchParams = new MetaboliteSearchRequest(
token, searchMass, adduct, searchTolerance, "Da");
LineInfo resultsData[][];
try {
resultsData = serv.metaboliteSearch(searchParams);
} catch (AxisFault e) {
// For some reason, the METLIN SOAP gateway throws AxisFault caused
// by ArrayStoreException if no result is found. I suspect their
// SOAP response is malformed and Axis does not like it.
resultsData = new LineInfo[1][0];
}
if (resultsData.length == 0) {
throw (new IOException("Results could not be retrieved from METLIN"));
}
final int totalResults = Math.min(resultsData[0].length, numOfResults);
String metlinIDs[] = new String[totalResults];
for (int i = 0; i < totalResults; i++) {
LineInfo metlinEntry = resultsData[0][i];
String metlinID = metlinEntry.getMolid();
retrievedMolecules.put(metlinID, metlinEntry);
metlinIDs[i] = metlinID;
}
return metlinIDs;