(axis2 1.3,struts2 2.1.8.1,tomcat 6.x,java 1.5.0)
我在制作第一个网络服务时遇到了问题。
我创建了一个我要测试的MOCK api。我的行动:
public HotelMessage[] getMessages(String roomNr) {
HotelMessage[] msg2return = new HotelMessage[1];
HotelMessage m1 = new HotelMessage();
m1.setId(1L);
m1.setMessage("wiadomosc pierwsza");
m1.setTitle("title pierwszy");
m1.setRead(false);
m1.setRoomNr(roomNr);
System.err.println("returning messages");
return msg2return;
}
我的HotelMessage课程看起来像这样:
import java.io.Serializable;
import java.sql.Date;
public class HotelMessage implements Serializable{
private static final long serialVersionUID = -6785924436619067967L;
private long id;
private boolean read;
private String roomNr;
private String title;
private String message;
private Date create_date;
//setters + getters
}
制作aar后,我将其上传到tomcat上的mu axis2,然后:
wsdl2java.bat -uri http://localhost:8088/axis2/services/HotelAPI?wsdl -d adb -s -S .
一切正常,但我得到了这个例外,而我试图用代码调用getMessages(“STH”)动作:
HotelAPIStub.GetMessages getMessages = new HotelAPIStub.GetMessages();
getMessages.setParam0("ble");
HotelAPIStub.HotelMessage[] tmp;
try{
HotelAPIStub.GetMessagesResponse resp3 = stub.getMessages(getMessages);
tmp = resp3.get_return();
System.err.println("THERE ARE "+tmp.length+"MESSAGES!");
}catch (RemoteException ex){
System.err.println("NO MESSAGES!");
ex.printStackTrace();
}
我有这个例外:
org.apache.axis2.AxisFault: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at com.swmind.IPTV.hotel.HotelAPIStub.getMessages(HotelAPIStub.java:371)
at com.swmind.IPTV.hotel.actions.ShowBillClass.execute(ShowBillClass.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
有人可以帮帮我吗?我试过谷歌,但没有找到任何有用的东西。 谢谢 Tzim
答案 0 :(得分:1)
在模拟API中,您永远不会将msg2return[0]
指向m1
。
答案 1 :(得分:0)
解决方案:重新启动带有axis2的tomcat ......