0
正在編寫SOAP Web服務方法,以使用java中的數字角色sdk將模板與功能集進行比較。我需要檢索數據庫中的字符串模板,然後將其轉換爲字節數組,以便與特徵集進行匹配。我的web方法的輸入參數是email和ftSet,它們都是字符串。 Ftset也需要轉換成字節數組,這些都是在try catch塊之後完成的。我怎樣才能訪問名爲「dbTemplate」的變量?無法從Web服務方法的try catch塊訪問參數
@WebMethod(operationName = "CheckTemplate")
public String CheckTemplate(@WebParam(name = "email") String email,
@WebParam(name = "ftSet") String ftSet) {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "1234");
PreparedStatement st;
st = con.prepareStatement("select template from Tbl_reg where email = ? ");
st.setString(1, email);
ResultSet result = st.executeQuery();
if (result.next()) { //.next() returns true if there is a next row returned by the query.
String dbTemplate = result.getString("template");
}
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
}
}
}
byte[] byteArray = new byte[1];
//dbTemplate is underlined here, cannot access it from the try catch
byteArray = hexStringToByteArray(dbTemplate);
DPFPTemplate template = DPFPGlobal.getTemplateFactory().createTemplate();
template.deserialize(byteArray);
byte[] fsArray = new byte[1];
fsArray = hexStringToByteArray(ftSet);
DPFPSample sample = DPFPGlobal.getSampleFactory().createSample();
sample.deserialize(fsArray);
DPFPFeatureSet features = extractFeatures(sample, DPFPDataPurpose.DATA_PURPOSE_VERIFICATION);
DPFPVerification matcher = DPFPGlobal.getVerificationFactory().createVerification();
DPFPVerificationResult result1 = matcher.verify(features, template);
if (result1.isVerified()) {
return "The fingerprint was VERIFIED.";
} else {
return "The fingerprint was NOT VERIFIED.";
}
}
好的非常感謝你。 但我現在正在得到另一個錯誤。它沒有返回任何東西。 ? 給我的錯誤:( – Div
什麼是不返回任何東西有什麼錯誤 –
,而不是返回指紋,驗證或沒有驗證正在此錯誤: 服務調用拋出異常與消息:無效;請參考服務器日誌更多詳細信息 異常詳細信息:java.lang.reflect.InvocationTargetException – Div