我知道这是另一个类似主题的话题,但我搜索了stackoverflow,我找不到问题的答案。 情况如下: 我有一个webservice让我们用很多方法称它为testservice。最近我不得不添加另一个,所以我做了:
public int addPayments_p24(String sessionId, int pos_id, String amount, String currency, String title, String client, String address, String postal, String city, String country, String email, String language, String p24_sign) throws Exception {
int last_inserted_id=0;
try {
PreparedStatement statement = null;
int timestamp = (int)(System.currentTimeMillis() / 1000L);
statement = connection
.prepareStatement(
"Insert into p24_strefa(pos_id,session_id,amount,currency,title,client,address,postal,city,country,email,language,p24_sign,timestamp)" +
"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);", statement.RETURN_GENERATED_KEYS);
statement.setInt(1, pos_id);
statement.setString(2, sessionId);
statement.setString(3, amount);
statement.setString(4, currency);
statement.setString(5, title);
statement.setString(6, client);
statement.setString(7, address);
statement.setString(8, postal);
statement.setString(9, city);
statement.setString(10, country);
statement.setString(11, email);
statement.setString(12, language);
statement.setString(13, p24_sign);
statement.setInt(14, timestamp);
statement.executeUpdate();
ResultSet rs = statement.getGeneratedKeys();
if(rs.next())
{
last_inserted_id = rs.getInt(1);
}
} catch (Exception ex) {
_log.error("addpayments_p24", ex);
throw ex;
}
finally {
dispose();
}
return last_inserted_id;
}
然后我尝试从jsp文件中调用此方法,如下所示:
String sessionId = request.getParameter( "p24_session_id" );
String amount = request.getParameter( "p24_amount" );
String currencys = request.getParameter("p24_currency");
String title = request.getParameter("p24_description");
String client = request.getParameter("p24_client");
String address = request.getParameter("p24_address");
String postal = request.getParameter("p24_zip");
String city = request.getParameter("p24_city");
String country = request.getParameter("p24_country");
String email = request.getParameter("p24_email");
String language = request.getParameter("p24_language");
String sign = get_sign_str(sessionId,amount,currencys);
int pos_id = 2414;
int testResponse;
try {
if (test== null) {
inittest();
}
testResponse = test.addPayments_p24("test",2,"test","test","test","test","test","test","test","test","test","test","test");
}
catch (testWebServicesExceptionException e)
{
e.printStackTrace();
}
与webservice的连接由此函数完成:
private static testWebServicesStub test;
private synchronized void inittest() throws AxisFault {
if (test == null) {
String testWebServicesEndpoint = Settings
.gettestWebServicesEndpoint();
test= new testWebServicesStub(testWebServicesEndpoint);
}
}
如您所见,我使用的是Axis2。 当然我得到了错误:
The method addPayments_p24(AddPayments_p24) in the type TestWebServicesStub is not applicable for the arguments (String, int, String, String, String, String, String, String, String, String, String, String, String)
我现在第三天坐在这个问题上,我无法理解。如果有人知道发生了什么......
我差点忘了app是在apache-tomcat 7.0.34上运行的,如果它改变了什么,但我已经在另一个版本上测试了。 当然,一切都被编译了多次,编译后我甚至反编译了所有内容以检查变量类型是否正确,当然它们是......
答案 0 :(得分:0)
我会尝试删除“抛出前”;并从addPayments_p24“抛出异常”。
答案 1 :(得分:0)
我暂时没有使用网络服务,所以我对此并不确定,但是,似乎你在两种方法之间混合,就像错误所暗示的那样,碰巧你正在调用方法
addPayments_p24(String, int, String, String, String, String, String, String, String, String, String, String, String)
它不存在于客户端,也不存在于它的接口(至少是可见的调用范围)。调用范围(在客户端中)中存在的方法是addPayments_p24(AddPayments_p24)
,因此您需要使用您想要的参数(String, int, String, String, String, String, String, String, String, String, String, String, String)
来实例化一个对象AddPayments_p24,不确定这个但似乎是真。